Partager via


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

  • Anonymous
    November 22, 2009
    This will be very handy! Would it be possible to make  the SwitchRoleCenter class available? Many thanks, Greg

  • Anonymous
    November 24, 2009
    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

  • Anonymous
    December 13, 2009
    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.

  • Anonymous
    December 28, 2010
    I get an error" Error executing code: <empty class> object does not have method 'main'.  (C)Classes<unknown>main What am I doing wrong?

  • Anonymous
    January 26, 2011
    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

  • Anonymous
    February 06, 2011
    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. :)