A short one! Some time ago I explained how to add a multi selection lookup to a SysOperation dialog and in this post I’ll explain how to add a Menu Item as a Function button to the SysOperation dialog.
Before the SysOperation Framework was introduced in AX2012, we used the RunBase Framework, and maybe doing these things looked easier/quickier with RunBase because all the logic was in a single class. But in the end what we need to do is practically the same but we have to do it in the UIBuilder class.
Let me show you and explain all the code. I’ll only show the DataContract and UIBuilder classes as they’re the only important ones in this case.
DataContract class
[
DataContract,
SysOperationContractProcessing(classStr(AASMenuItemDemoUIBuilder)),
SysOperationGroup('VendGrp', 'Vendor', '1')
]
class AASMenuItemDemoDataContract
{
VendAccount vendAccount;
[
DataMember,
SysOperationGroupMember('VendGrp')
]
public VendAccount parmVendAccount(VendAccount _vendAccount = VendAccount)
{
vendAccount = _vendAccount;
return vendAccount;
}
}
Please don’t look at all the hardcoding 😛
On the DataContract class I’ve defined a VendAccount member. I’ve also created a group using the SysOperationGroup attribute and put the VendAccount field inside using the SysOperationGroupMember attribute in the parm method.
The UIBuilder class is also set in the SysOperationContractProcessing attribute.
UIBuilder class
class AASMenuItemDemoUIBuilder extends SysOperationAutomaticUIBuilder
{
FormBuildFunctionButtonControl menuItemBtn;
FormBuildGroupControl vendorGrp;
public void build()
{
super();
vendorGrp = this.dialog().formBuildDesign().control('VendGrp');
menuItemBtn = vendorGrp.addControl(FormControlType::MenuFunctionButton, 'AASVendTableBtn');
menuItemBtn.menuItemType(MenuItemType::Display);
menuItemBtn.menuItemName(menuItemDisplayStr(VendTable));
}
}
All the things we need to do to modify the dialog of the SysOperation Framework must be done in the UIBuilder class. What we need to is the same we would have done using the RunBase framework. Get the controls from the dialog and modify or add its elements.
We get the vendor group we created in the Data Contract class and add a control to it. This control is of type MenuFunctionButton and once it’s created we define it’s properties and it’s done.