We're trying to fulfil a requirement to be able to assign different properties to a certain form controls under different companies, and is trying to achieve it using some generic code rather than doing it on a per-form basis.
We've tried the following code to loop all controls within a form, however is unsuccessful, the code only returned button controls within the top action pane.
Any idea how to revise it to make it work, for example, to be able to return all individual field controls under a grid, in the SalesTable form?
[ExtensionOf(classStr(FormRun))]
final class XXX_FormRun_Extension
{
public void run()
{
next run();
for (int i = 1; i <= this.form().design().controlCount(); i++)
{
this.XXX_iterateControls(this.form().design().controlNum(i));
}
}
protected void XXX_iterateControls(FormBuildControl formBuildControl)
{
info(strFmt("%1 %2", formBuildControl.isContainer(), formBuildControl.controlCount()));
if (formBuildControl.isContainer())
{
for (int j = 1; j < formBuildControl.controlCount(); j++)
{
//Process container, if you need to
this.XXX_iterateControls(formBuildControl.controlNum(j));
}
}
else
{
//Control is not a container, process it here.
info(strFmt("%1 %2", classId2Name(formBuildControl.handle()), formBuildControl.name()));
switch (formBuildControl.handle())
{
case classNum(FormBuildRealControl):
info("Found");
break;
}
}
}
}