Home > Computer Programming, dynamics ax 2009, dynamics ax 2012 > how to get list of all menu items at ax, and the license on it

how to get list of all menu items at ax, and the license on it


friends, the common problem using ax 2012 is the license, we don’t know which menu items is enterprise, or functional, or task or self serve,

i’m doing some research from sysuserlicenseminer class from ax, and with a little modification i got what i want

that is, list off all menu items, with the license in it and saves it to csv files

just change the file name and listnodepath to get another type of menu items

this is the source code

static void ronny_createamenulicenselist(Args _args)
{
    #Properties
    #AOT

    #define.PropertyReadUserLicense('ViewUserLicense')
    #define.PropertyFullAccessUserLicense('MaintainUserLicense')

    SecurableObject securableObject;
    TreeNode listNode, itemNode;
    TreeNodeIterator itemNodeIt;
    str itemConfigurationKey;

    Map typeSet = new Map(Types::String, Types::Enum);

    void processMenuItemList(str listNodePath, EntryPointType entryType)
    {
        int entryTypeId;
        str tipelisensi;
        //ronny-start
        TextIo file;
        Filename filename = @"c:\ronny\ronny-listmenu-action.csv";
        container con;
        FileIOPermission permission;
        int i;
        #File
        try{
            permission = new FileIOPermission(filename,#io_write);
            permission.assert();
            file = new TextIo(filename,#io_write);

            if(!file)
                    throw Exception::Error;

            file.outRecordDelimiter(#delimiterCRLF);
            file.outFieldDelimiter("");
            con= conNull();
            //ronny-end

            listNode = TreeNode::findNode(listNodePath);
            itemNodeIt = listNode.AOTiterator();
            itemNode = itemNodeIt.next();
            while (itemNode)
            {

                // Process only items with configuration key enabled (or empty)
                itemConfigurationKey = itemNode.AOTgetProperty(#PropertyConfigurationKey);
                if(!itemConfigurationKey || isConfigurationkeyEnabled(configurationKeyName2Id(itemConfigurationKey)))
                {
                    entryTypeId = entryType;

                    select RecId from securableObject
                        where SecurableObject.Type == entryTypeId
                            && SecurableObject.Name == itemNode.AOTgetProperty(#PropertyName)
                            && SecurableObject.ChildName == '';

                    tipelisensi = "";
                    i++;
                    switch(typeSet.lookup(itemNode.AOTgetProperty(#PropertyReadUserLicense)))
                    {
                        case 0: tipelisensi = "none"; break;
                        case 1: tipelisensi = "selfserve"; break;
                        case 2: tipelisensi = "task"; break;
                        case 3: tipelisensi = "functional"; break;
                        case 4: tipelisensi = "enterprise"; break;
                    }
                    con = conIns(con,i,strFmt("%1|%2|%3|%4|%5\n",SecurableObject.RecId,
                        itemNode.AOTgetProperty(#PropertyName),entryType, AccessRight::View,
                        tipelisensi));
                    i++;
                    switch(typeSet.lookup(itemNode.AOTgetProperty(#PropertyFullAccessUserLicense)))
                    {
                        case 0: tipelisensi = "none"; break;
                        case 1: tipelisensi = "selfserve"; break;
                        case 2: tipelisensi = "task"; break;
                        case 3: tipelisensi = "functional"; break;
                        case 4: tipelisensi = "enterprise"; break;
                    }
                    con = conIns(con,i,strFmt("%1|%2|%3|%4|%5\n",SecurableObject.RecId,
                        itemNode.AOTgetProperty(#PropertyName),entryType, AccessRight::Delete,
                        tipelisensi));
                }

                itemNode.treeNodeRelease();
                itemNode = itemNodeIt.next();
            }
            file.writeExp(con);
            info("done");
        }
        catch(Exception::Error)
        {
            error("masalah");
        }
    }
    typeSet.insert('', UserLicenseType::None);
    typeSet.insert('None', UserLicenseType::None);
    typeSet.insert('SelfServe', UserLicenseType::SelfServe);
    typeSet.insert('Task', UserLicenseType::Task);
    typeSet.insert('Functional', UserLicenseType::Functional);
    typeSet.insert('Enterprise', UserLicenseType::Enterprise);

    // Insert the records for menu item entry points
    //processMenuItemList(#MenuItemsDisplayPath, EntryPointType::MenuItemDisplay);
    //processMenuItemList(#MenuItemsOutputPath, EntryPointType::MenuItemOutput);
    processMenuItemList(#MenuItemsActionPath, EntryPointType::MenuItemAction);
    //processMenuItemList(#WebMenuItemsUrlPath, EntryPointType::WebUrlItem);
    //processMenuItemList(#WebMenuItemsActionPath, EntryPointType::WebActionItem);
    //processMenuItemList(#WebContentItemsManagedPath, EntryPointType::WebManagedContent);
  1. No comments yet.
  1. No trackbacks yet.

Please kindly Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: