Hello everyone,
I need to use onlookup event to filter my data based on another table in form.
I have inventsite form and 2 tables with 1:N relation in it. One of them is SitePI and other one PITrans.
Here is the scenario: I go to InventSite form and add a site named test and I go to SitePI table ( it is in the fast tab) I add records (001, 004, 005), I add another site named test2 and add records 003,006,007 for its SitePI. lastly, I go to PITrans table ( It is in the another fast tab,) and when I press the drop-down I need to able to select records that belong to SitePI table as lookup.
But I can see only the selected record.

I need to see 001, 004 and 005 when I select records.
Here is my code ( PICode is RefRecId for my lookup table)
[FormControlEventHandler(formControlStr(InventSite, PITrans_PICode), FormControlEventType::Lookup)]
public static void PITrans_PICode_OnLookup(FormControl sender, FormControlEventArgs e)
{
SysReferenceTableLookup tableLookup = SysReferenceTableLookup::newParameters(tableNum(SitePI), sender);
Query query = new Query();
SitePI sitePI = sender.formRun().dataSource('SitePI').cursor();
InventSite inventSite = sender.formRun().dataSource('InventSite').cursor();
QueryBuildDataSource qbds = query.addDataSource(tableNum(SitePI));
qbds.addRange(fieldNum(SitePI, PICode)).value(queryValue(sitePI.PICode));
query.dataSourceTable(tableNum(SitePI)).addOrderByField(fieldNum(SitePI, PICode), SortOrder::Ascending);
tableLookup.addLookupField(fieldNum(SitePI, PICode));
tableLookup.parmQuery(query);
tableLookup.performFormLookup();
FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
ce.CancelSuperCall();
I would be really appreciated it if anyone can help me.
Regards
jennifer