Explore AX.com

Skip to content
  • Home
  • About Me
  • Questions?
  • X++ 101

Explore AX.com

Don’t only practice your art, but force your way into its secrets

Skip to content
  • Home
  • About Me
  • Questions?
  • X++ 101

Approve By Email

Approve your AX 2009 and 2012 Workflows direct from your inbox with Axnosis Email Approver. Works with Outlook, Blackberry, Android, iPad, iPhone etc...

Recent Posts

  • Electronic reporter: New line in a word template content control
  • AX/D365 SSRS Report: “: Error 1 : Format is invalid. “
  • Report not working “This report doesn’t exist just yet”
  • Powershell/GIT – Create PackageLocalDirectory Symlinks
  • Saving Company Logo to file (X++)

Categories

  • AIF
  • AX2012
  • Client
  • Dynamics AX
  • Environment Management
  • Further Reading
  • Integration
  • Jobs
  • Model Management
  • Quick Tips
  • Role Centers
  • Security
  • SQL Scripts
  • SSRS
  • Training
  • Uncategorized
  • Workflow
  • X++

Archives

  • May 2024
  • August 2023
  • June 2023
  • April 2023
  • May 2018
  • February 2018
  • January 2018
  • January 2016
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Recent Posts

  • Electronic reporter: New line in a word template content control
  • AX/D365 SSRS Report: “: Error 1 : Format is invalid. “
  • Report not working “This report doesn’t exist just yet”
  • Powershell/GIT – Create PackageLocalDirectory Symlinks
  • Saving Company Logo to file (X++)

Archives

  • May 2024
  • August 2023
  • June 2023
  • April 2023
  • May 2018
  • February 2018
  • January 2018
  • January 2016
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014

Categories

  • AIF
  • AX2012
  • Client
  • Dynamics AX
  • Environment Management
  • Further Reading
  • Integration
  • Jobs
  • Model Management
  • Quick Tips
  • Role Centers
  • Security
  • SQL Scripts
  • SSRS
  • Training
  • Uncategorized
  • Workflow
  • X++

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

About

Welcome to my blog, a place where I record my thoughts and discoveries as I explore the Dynamics AX landscape.

Online XPO Reader (Beta)

Online XPO Reader

Personalise

1 Comment Posted on September 18, 2015 AX2012, Client, Dynamics AX, Quick Tips, X++

Share AX User Form Customizations Between Companies

One of the nifty features of Dynamics AX is to share form personalisations between user. To see how to do so check out Murray Fife’s article over here. However it seems that a distinct restriction is that you cannot effectively share personalisations between companies, even for the same user. This means that you need to perform the same setups for every form that you are working on.

I thought I would share with you today a quick customization that will assist allow you to copy your own customizations from one company to another or copy from a different user’s profile in another company to yours.

Our customization will make a modification to the “SysSetupForm” in AX. This is the form that is displayed when right clicking on a field in AX and clicking “Personalise”

In this post we will basically duplicate the “Retrieve from User” button to provide a “Retrieve from Alternate company” option in addition to the basic functionality. You could also simply customize the standard function as well.

Step 1. Create a new button

  • Navigate in the AOT to the forms node and find “SysSetupForm”
  • Expand the following nodes “SysSetupForm->Designs->Design->Tab:ControlTab->TabPage:LayoutTab-> Group:RightGrp -> ButtonGroup:MainBtnGroup.
  • Right click on ButtonGroup:MainBtnGroup, click “New Control -> Button”
  • Set the button’s “Text” property to “Retrieve from Company”

Step 2. Update button to display profiles from all users and companies

  • Right click on the method’s node of your button, click Override Method -> clicked
  • In the clicked method add the following line of code: element.loadFromUserAll(); 
  • Navigate to the methods node of the SysSetup form, right click and click “New Method”
  • Rename your new method to: loadFromUserAll
  • Modify this method’s code the following (this is basically a modified copy of the loadFromUser method to cater for cross company lookups)
void loadFromUserAll()
{
    SysLastValue sysLastValue;
    userId       userId;
    CompanyId    companyId;
    ;
    if (!loadFromUserMapAll)
    {
        loadFromUserMapAll     = new Map(Types::String, Types::String);

        while select sysLastValue
            group by UserId, Company
            where sysLastValue.Company      != this.lastValueDataAreaId()
               && sysLastValue.RecordType   == UtilElementType::Usersetup
               && sysLastValue.ElementName  == this.lastValueElementName()
               && sysLastValue.DesignName
        {
            loadFromUserMapAll.insert(sysLastValue.UserId+"|"+sysLastValue.company, strFmt("%1 (%2)", sysLastValue.UserId, sysLastValue.company));
        }
    }

    if (loadFromUserMapAll.elements())
    {
        [userId,companyId] = str2con(pickUser(loadFromUserMapAll, true),"|");

        if (userId)
        {
            element.loadSetupCompany(userId,companyId);
        }
    }
    else
    {
        info("@SYS73299");
    }
}
  • Edit SysSetupForm’s Class declaration to  declare a new variable: “Map loadFromUserMapAll;

Step 3: Provide logic to load the setup on selection

  • Navigate to the methods node of the SysSetup form, right click and click “New Method”
  • Rename your new method to:
    public void loadSetupCompany(userId userId, CompanyId _company)
  • Modify this method’s code the following (this is basically a modified copy of the loadSetup method to cater for loading from a selected alternate company setup)
// AosRunMode::Client
public void loadSetupCompany(userId userId, CompanyId _company)
{
    SysLastValue    sysLastValue;
    container       value;
    Name            designName;
    Map             map;
    ;

    select firstonly sysLastValue
        where sysLastValue.Company      == _company  &&
              sysLastValue.UserId       == userId                      &&
              sysLastValue.RecordType   == this.lastValueType()  &&
              sysLastValue.ElementName  == this.lastValueElementName() &&
              sysLastValue.DesignName   != '';

    if (sysLastValue)
    {
        map = new Map(Types::String, Types::String);

        while select designName from sysLastValue
            where sysLastValue.Company      == _company   &&
                  sysLastValue.UserId       == userId                       &&
                  sysLastValue.RecordType   == this.lastValueType()         &&
                  sysLastValue.ElementName  == this.lastValueElementName()  &&
                  sysLastValue.DesignName   != ''
        {
            map.insert(sysLastValue.DesignName, sysLastValue.DesignName);
        }

        designName = pickList(map, "@SYS28107","@SYS28107", true);
        if (designName)
        {
            value = xSysLastValue::getValue(
                _company,
                userId,
                this.lastValueType(),
                this.lastValueElementName(),
                designName);


            xSysLastValue::putValue(
                value,
                this.lastValueDataAreaId(),
                curUserId(),
                this.lastValueType(),
                this.lastValueElementName(),
                '');

            element.disableLayoutChanges();
        }
    }
    else
    {
        info(strfmt("@SYS28106", userId));
    }
}

You’re all done! 

Compile your form and access it from anywhere in AX by right clicking on a field and clicking Personalise.

Personalise

You should now have a “Retrieve from Company” button.

2015-09-18_0755

 

When clicking on this button you will see a list of all user profiles for other companies, including your own with the company listed in brackets. Double click on the user name, then double click on the the personalisation name to load it.

I hope this helps make life more efficient and easy!

 

 

 

Development tricks Personalise User Settings
Proudly powered by WordPress | Theme: Adaption by WordPress.com.