Add all Role Centers to AX Client Favorites for demo purpose


Run this job in AX Client to add all oob role centers to your favorites section in AX Client for easy demo purpose. 


static void AddRoleCentersToFavorite(Args _args)
{
str sDefault =”Default”;
SysProfiles uprofile;
MenuFunction mf;
TreeNode treeNode;
    TreeNodeIterator iterator;
    TreeNode newTreeNode;
    UserMenuList userMenu;
    Menu menuNode;
    #AOT
;


 treeNode = infolog.userNode();
    iterator = treeNode.AOTiterator();
    treeNode = iterator.next();
    if (treeNode)
    {
        userMenu = treeNode;


        // find ‘My Favorites’ user menu; if not found, create one
        treeNode = userMenu.AOTfindChild(“@SYS95713”);
        if (!treeNode)
        {
            userMenu.createMenu(“@SYS95713”);
            treeNode = userMenu.AOTfindChild(“@SYS95713”);
        }
        menuNode = treeNode;


while select ProfileId from uprofile
{


mf = new MenuFunction(“DemoRoleCenter”+uprofile.ProfileId,MenuItemType::Action);
mf.AOTsetProperty(“Label”,uprofile.ProfileId);
mf.AOTsetProperty(“ObjectType”,”Class”);
mf.AOTsetProperty(“Object”,”SwitchRoleCenter”);
mf.AOTsetProperty(“Parameters”,uprofile.ProfileId);


mf.AOTsave();
menuNode.addMenuitem(mf);
menuNode.save();
}


mf = new MenuFunction(“DemoRoleCenter”+sDefault,MenuItemType::Action);
mf.AOTsetProperty(“Label”,sDefault);
mf.AOTsetProperty(“ObjectType”,”Class”);
mf.AOTsetProperty(“Object”,”SwitchRoleCenter”);
mf.AOTsetProperty(“Parameters”,sDefault);


mf.AOTsave();
menuNode.addMenuitem(mf);
menuNode.save();



        infolog.navPane().refreshFavorites(“@SYS95713”);


    }
}

Comments (6)

  1. Greg says:

    This will be very handy!

    Would it be possible to make  the SwitchRoleCenter class available?

    Many thanks,

    Greg

  2. Gerard says:

    Hi, I just discovered this web. It has usefull resources.

    It would be very hopefully if you could upload the SwitchRoleCenter class or explain some ideas to developed it.

    Many thanks

  3. Greg says:

    Another way to view all role centers for demos purposes is to use the Administration / Setup / User Profiles form. You can then choose the role and click the ‘View Role Centre’ button for any profile.

  4. eshuss says:

    I get an error" Error executing code: <empty class> object does not have method 'main'.

    

    (C)Classes<unknown>main

    What am I doing wrong?

  5. Bo says:

    I am gettíng the same error as eshuss:

    error" Error executing code: <empty class> object does not have method 'main'.

    

    (C)Classes<unknown>main

  6. Hans @ Qurius.nl says:

    Just create the SwitchRoleCenter class and add the following method:

    static void main(Args args)

    {

       URL homepageSite;

       URL homepageURL;

       Profile profile;

       ProfileManager profileMgr = infolog.profileMgr();

       #Web

       ;

       if (!profileMgr)

           return;

       //Get the homepage site

       homepageSite = EPGlobalParameters::homepageSiteURL();

       if (!homepageSite)

       {

           error("@SYS105504");

           return;

       }

       profile = profileMgr.getProfile(args.parm());

       if (profile)

           homepageURL = profile.homepageURLPath();

       if (homepageURL)

       {

           //Create full homepage URL, including company

           homepageURL = homepageSite + '/' + homepageURL + '?' + #epParamCompany + '=' + curext();

           infolog.urlLookup(homepageURL);

       }

    }

    Yup, it is just the code from User Profiles form now using the parameter from the menu item. 🙂