Wednesday, July 13, 2016

SysOperationAutomaticUIBuilder (SysOperationUIBuilder) amd Nested Data Contracts

Shame on me, but this the only way I found to get access to form controls exposed from a nested data contract.

Say, we have a data contract (blue) with a nested data contract (orange).



Both will be exposed to the dialog; however, we can have access via binding info to the main contract parameters only. For example, we can change some properties of these fields in postBuild() method in its SysOperationAutomaticUIBuilder (SysOperationUIBuilder) class like follows.


public void postBuild()
{
    DialogField                             dialogField;
    SysOperationUIBindInfo                  bindInfoLoc    = this.bindInfo();

    super();

    contract = this.dataContractObject();

    dialogField = bindInfoLoc.getDialogField(contract, methodStr(****CheckPostContract, parmJournalId));
    dialogField.allowEdit(false);
}

However, we cannot do the same way for parameters from the nested data contract. To attain this goal we can, however, iterate all the form build controls to find the one we need to change. In my example, I used the label of the exposed Currency EDT.


private void setCurrencyCodeFieldMandatory(FormBuildGroupControl _nestedContractGroup //nestedContractGroup)
{
    FormBuildStringControl                  currencyFormBuildStringControl;
    int                                     i;
    Object                                  childControl;

    for (i = 1; i <= _nestedContractGroup.controlCount(); i++) 
    {
        childControl = _nestedContractGroup.controlNum( i );
        if(childControl is FormBuildStringControl)
        {
            currencyFormBuildStringControl  = childControl;
            if(currencyFormBuildStringControl.label() == "@SYS7572")
            {
                currencyFormBuildStringControl.mandatory(true);
            }
        }
    }
}