Hi,
I built my own report using DP, Controller and Contract class. Everything was working fine, but I have 2 parameters, Resource and ResourceGroup (both WrkCtrId type).
The problem is when I open Controller, the combo box of parameters only displays resources (Type : Machine or Location) and no resource groups (whereas they are stored in the same table : WrkCtrTable).
So my work around was to add an UIBuilder class for my report and override the lookup and postBuildmethod, this way :
public void lookupResourceGroup(FormStringControl _formStringControl) { Query query = new Query(); QueryBuildDataSource DataSource; SysTableLookup sysTablelookup; //create a table lookup sysTablelookup = SysTableLookup::newParameters(tableNum(WrkCtrTable),_formStringControl); sysTablelookup.addLookupfield(fieldNum(WrkCtrTable,WrkCtrId)); sysTablelookup.addLookupfield(fieldNum(WrkCtrTable,Name)); sysTablelookup.addLookupfield(fieldNum(WrkCtrTable,WrkCtrType)); //create a query DataSource = query.addDataSource(tableNum(WrkCtrTable)); DataSource.addRange(fieldNum(WrkCtrTable,WrkCtrType)).value(enum2str(WrkCtrType::Group)); sysTablelookup.parmQuery(query); sysTablelookup.performFormLookup(); } ------------------------------------------------------------------------------------- public void postBuild() { DialogField dlgCustGroup; super(); dlgCustGroup = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(DailyProdContract,parmResourceGroup)); //register the method we want to override dlgCustGroup.registerOverrideMethod( methodStr(FormStringControl, lookup), methodStr(DailyProdUIBuilder,lookupResourceGroup), this); }
So, after I added the range to select only resource groups, it works, the comboBox displays the right values. But once I select one I get the error "The value '***' in field 'WrkCtrId' is not found in the related table 'WrkCtrTable'."
I've put a breakpoint (in Classes\Info\add() method) to locate the cause, it looks like the exception is coming from Classes\FormStringControl\Validate().
So I have 2 questions : Why does my resource and resourceGroup parameters only looks up values of type Machine in the first place ? And how can I work around this problem?
*This post is locked for comments