Hi team,
I have 3 lookup fields Asset Group, Asset Type and Asset category.
I need to display the lookup based on another lookup value in D365FO.
for example -
If I select Asset group AG001 from lookup then it should display the lookup in Asset type and Asset Category which is associated with AG001 only. NOT all the values.
If I select Asset Type AT005 from lookup, then it should display the lookup in Asset Group and Asset Category which is associated with AT001 only. NOT all the values.
If i select Asset Category AC009 from lookup, then it should display the lookup in Asset Group and Asset Type which is associated with AC001 only. NOT all the values.
Kindly let me know how to acheive this?
Please give me more shed on this.
thanks!
/*Asset Category*/ [FormControlEventHandler(formControlStr(EntAssetObjectTableCreate, ObjectTable_HSAssetCategory), FormControlEventType::Lookup)] public static void ObjectTable_HSAssetCategory_OnLookup(FormControl sender, FormControlEventArgs e) { FormRun element; FormControl formCtrl; Query query; QueryBuildDataSource qbdsEntAssetObjectTable;//, hsAssetGroup; SysTableLookup sysTableLookup; element = sender.formRun(); formCtrl = element.design().controlName(formControlStr(EntAssetObjectTableCreate, ObjectTable_HSAssetCategory)); sysTableLookup = SysTableLookup::newParameters(tableNum(EntAssetObjectTable), sender); query = new Query(); qbdsEntAssetObjectTable = query.addDataSource(tableNum(EntAssetObjectTable)); sysTableLookup.addLookupfield(fieldNum(EntAssetObjectTable, AssetGroup)); qbdsEntAssetObjectTable.addRange(fieldNum(EntAssetObjectTable, AssetCategory)).value(formCtrl.valueStr()); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); }
Use this code. I have see that some other table also used. Is that also a table? if yes you have to give the table link in query.
Hi Bharani,
/*Asset Category*/ [FormControlEventHandler(formControlStr(EntAssetObjectTableCreate, ObjectTable_HSAssetCategory), FormControlEventType::Lookup)] public static void ObjectTable_HSAssetCategory_OnLookup(FormControl sender, FormControlEventArgs e) { FormRun element; FormControl formCtrl; Query query; QueryBuildDataSource EntAssetObjectTableCreate;//, hsAssetGroup; SysTableLookup sysTableLookup; element = sender.formRun(); formCtrl = element.design().controlName(formControlStr(EntAssetObjectTableCreate, ObjectTable_HSAssetCategory)); sysTableLookup = SysTableLookup::newParameters(tableNum(HSAssetgroup), sender); query = new Query(); EntAssetObjectTableCreate = query.addDataSource( EntAssetObjectTableCreate = query.addDataSource(tableNum(HSAssetgroup)); sysTableLookup.addLookupfield(fieldNum(HSAssetgroup, AssetGroup)); EntAssetObjectTableCreate.addRange(fieldNum(HSAssetgroup, AssetCategory)).value(formCtrl.valueStr()); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); }
Below I will give ypu the table name
the form is - EntAssetObjectTableCreate
form- data source - EntAssetObjectTbale
Asset category - HSAsetCategory
Pls give me more sked on this. thanks!
Asset group - HSAssetGroup
Can you send your code? Because I don't know your table names exactly.
Hi Bharani,
Kindly send me the code pls, what you explain to change.
I have done that but same result
Line 24: Change the name of the table buffer to table name in tableNum method.
Same in 26 you have added the buffer in tablenum method. It should be table name.
Like QueryBuildDataSource qbdsTableName; one buffer is enough.
In 24 you will add the original table name beside sender.
In 26 you have to give like qbdsTableName = query.addDataSource(tableNum(TableName));
And similarly change accordingly in 28 and 29. Then do build and sync and check.
Do exactly as the links provided.
Hi All,
Asset Category lookup is showing below values.
Suppose I select the value AS002 from Asset Category
Then I am looking for Asset Group lookup only those values which is only related to AS002 but it showing all the values as below
But I am looking for the value only OFFICE from the Asset Category lookup
To achieve this, I wrote below code but it is not working. Kindly let me know where is wrong?
class HSAssetObjectTableCreate { ////// /// /// /// /*Asset Category*/ [FormControlEventHandler(formControlStr(EntAssetObjectTableCreate, ObjectTable_HSAssetCategory), FormControlEventType::Lookup)] public static void ObjectTable_HSAssetCategory_OnLookup(FormControl sender, FormControlEventArgs e) { FormRun element; FormControl formCtrl; Query query; QueryBuildDataSource EntAssetObjectTableCreate, hsAssetGroup; SysTableLookup sysTableLookup; element = sender.formRun(); formCtrl = element.design().controlName(formControlStr(EntAssetObjectTableCreate, ObjectTable_HSAssetCategory)); sysTableLookup = SysTableLookup::newParameters(tableNum(hsAssetGroup), sender); query = new Query(); EntAssetObjectTableCreate = query.addDataSource(tableNum(hsAssetGroup)); sysTableLookup.addLookupfield(fieldNum(hsAssetGroup, AssetGroup)); EntAssetObjectTableCreate.addRange(fieldNum(hsAssetGroup, AssetCategory)).value(formCtrl.valueStr()); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); } }
Pls give me more shed on this.
thanks!
Hi Baharani,
What cancelsupercall does ?
When it is actual required to call ?
Pls. give me more shed on this.
thanks!
Thanks Baharani, I will update you
Presently I donot have a laptop or vm.
Use the below code which is in the method which actually helps your requirement.
Also give a condition for range if that field value exists only then add this range. As said earlier it is not required to call cancelsupercall.
Yes, you mean to say I need to write syslookup for all 3 event handlers ?
Kindly send me the sample code pls
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156