[X++] parameters in SysOperationGroupAttribute LabelType

When it comes to SysOperationFramework (also known as BusinessOperationFramework) dialogs, groups can be defined in the corresponding DataContract class.
(I masked the object names cause the codes comes from my current implementation for a customer, so don't wonder about the names.)
Best Practice is to define the groups in the classDeclaration:

#define.GroupMyFirstGroup('FirstGroup')
#define.GroupMyFirstGroupLabel("@SYS96096")
#define.GroupMyFirstGroupOrderKey('10')
#define.GroupMySecondGroup('SecondGroup')
#define.GroupMySecondGroupLabel("@SYS96096")
#define.GroupMySecondGroupOrderKey('11')
[
    DataContractAttribute,
    SysOperationGroupAttribute(#GroupMyFirstGroup, #GroupMyFirstGroupLabel, #GroupMyFirstGroupOrderKey),
    SysOperationGroupAttribute(#GroupMySecondGroup, #GroupMySecondGroupLabel, #GroupMySecondGroupOrderKey),
    SysOperationContractProcessingAttribute(classStr(MyUIBuilderClass), SysOperationDataContractProcessingMode::CreateSeparateUIBuilderForEachContract)
]
class MyContract
{
    str                                 packedQuery;
    PriceDiscAccountRelation            accountRelation;
    ItemId                              itemId;
    // ...
}

As you can see, I'm using the label @SYS96096 which is "Group %1".
Now we want to add a value to be used as %1. In my case i want to use the current company.
We get the current company with the function curext() but AX throws an error if we want to use it like this:

SysOperationGroupAttribute(#GroupMyFirstGroup, strfmt("@SYS96096", curext()), #GroupMyFirstGroupOrderKey)

It seems there are no function calls are allowed here.

My workaround is to set the caption of my group in the UIBuilder class in method postBuild:

public void postBuild()
{
    #define.FormGroupName('FirstGroup')
    MyContract    contract;
    FormBuildGroupControl   groupFirstGroup;

    super();

    // get reference to dialog control
    if (this.dialog().formBuildDesign().control(#FormGroupName) is FormBuildGroupControl)
    {
        groupFirstGroup = this.dialog().formBuildDesign().control(#FormGroupName);
        // set the caption properly
        groupFirstGroup.caption(strFmt("@SYS96096", curext()));
    }
}

Robin

Software Engineer / Application Developer

Subscribe to robsCode

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!