Reference Data Sources in Form.

Hello,

So the question is: how to add Reference Data Source in Form using Form class.

Code looks something like this:

static void createForm()
{

    Form form;
    FormBuildDataSource formBuildDataSource;
...

    form = new Form();

    dictTable = new DictTable(tablenum(CustTable));
    formBuildDataSource = form.addDataSource(dictTable.name());
    formBuildDataSource.table(dictTable.id());

  ...
}
And I would love to add a Reference Data Source for example with HcmWorker table.

Any ideas how to do that?

I believe that a reference data source is just a normal data source added automatically by AX at design time. If you’re building a form at runtime, you would have to do it by yourself by calling addDataSource().

But why do you need it at all? Just add a reference group and AX will deal the rest. An example:

FormBuildReferenceGroupControl refGroupCtrl;
refGroupCtrl = formDesign.addControl(FormControlType::ReferenceGroup,
                                     "RefGroup");
refGroupCtrl.dataSource(formBuildDataSource.id());
refGroupCtrl.referenceField(fieldNum(CustTable, Party));