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.
You should now have a “Retrieve from Company” button.
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!