Hello,
I am working in AX7.
I have created a multiselect lookup field in my form. Lookup works fine.
But after selecting the values from the lookup and when i try to access the lookup again for a different row or for the same field, the previously selected values are still selected and it is not getting unselected until i have to unselect manually.
Can anyone suggest me why this is happening.
I have used the following code,
[FormControlEventHandler(formControlStr(Reasons, AssetTransactionType), FormControlEventType::Lookup)] public static void AssetTransactionType_OnLookup(FormControl sender, FormControlEventArgs e) { FormRun formRun = sender.formRun() as FormRun; TransactionType_TMP transactionType_TMP; TransactionType_TMP_Populate transactionType_TMP_Populate = new TransactionType_TMP_Populate(); transactionType_TMP_Populate.populateTempTable(transactionType_TMP); queryRun = new QueryRun(queryStr(TransactionType_TMPQuery)); queryRun.setCursor(transactionType_TMP); FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs; sysLookupMultiSelectCtrl = SysLookupMultiSelectCtrl::constructWithQueryRun(formRun,sender,queryRun/*,false,[tableNum(TransactionType_TMP),fieldNum(TransactionType_TMP,TransType)]*/); ce.CancelSuperCall(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormControlEventHandler(formControlStr(Reasons, AssetTransactionType), FormControlEventType::Modified)] public static void AssetTransactionType_OnModified(FormControl sender, FormControlEventArgs e) { FormDataSource reasonTable_ds = sender.formRun().dataSource("ReasonTable"); FormDataSource transactionType_TMP_ds = sender.formRun().dataSource("TransactionType_TMP"); SysQueryForm sysQueryForm = new SysQueryForm(queryRun); container reason; container reasonRecId; ReasonTable reasonTable; ReasonTable reasonUpdate; DefaultReasonTable defaultReasonTable; int value; int id; reasonTable = sender.formRun().dataSource(1).cursor(); reason = sysLookupMultiSelectCtrl.getSelectedFieldValues(); reasonRecId = sysLookupMultiSelectCtrl.get(); ttsbegin; select forupdate reasonUpdate where reasonUpdate.RecId == reasonTable.RecId; reasonUpdate.TransactionType = con2Str(sysLookupMultiSelectCtrl.getSelectedFieldValues(),';'); reasonUpdate.update(); reasonTable_ds.research(true); //queryRun.detach(); //queryRun.saveUserSetup(false); //reasonTable_ds.refresh(); //transactionType_TMP_ds.research(); //transactionType_TMP_ds.refresh(); while select forupdate defaultReasonTable where defaultReasonTable.ReasonRecId == reasonTable.RecId { defaultReasonTable.delete(); } defaultReasonTable.clear(); defaultReasonTable.initValue(); for(value = 1; value <= conLen(reasonRecId); value++) { defaultReasonTable.ReasonRecId = reasonTable.RecId; for(value = 1; value <= conLen(reason); value++) { defaultReasonTable.TransactionType = conPeek(reason,value); defaultReasonTable.insert(); } } ttscommit; }
Thanks
*This post is locked for comments
If the event handlers are in the same class then declare it as global static variables.
Hello,
How can i use the same variable sysLookupMultiSelectCtrl , queryRun within different event handlers? Please suggest
Thanks.
I checked with the standard, I have done the same thing what they have done.
Ans sysLookupMultiSelectCtrl.set(conNull()); worked form me.
I got the solution and its working fine.
Try to look at standard example like logisticsPostalAddress form or vendtable form . ALso try to set
sysLookupMultiSelectCtrl.set(conNull());
Did you already look at examples in the standard as I had suggested in two earlier replies?
There is no link between the selection and the main table. I created this table transactionType_TMP to populate the enum values in the table and I have added the table in the query to display it as a lookup.
I first tried to create it as a temp table but the I didn't get the lookup that's why I changed it into a regular table. I have created a new field in reason table and the selected values are stored in the reasonTable itself. So there is no link with the lookup table and the main table.
I do think there is something forgotten on the link between the main table and the selection table. Can you review if the table does have a reference field for what record the selection was saved?
Also compare the coding and tables used with a standard example (e.g. address books on party)
Hello!.
Sorry for the hurry.
Yes it allows to store data. Its not a temporary table. Its a regular table.
Thanks
Hi Wekey,
Note that we are all volunteers on this forum. You cannot expect an answer within one hour. We answer questions in spare time.
Is your transactionType_TMP table a temporary table or does it allows for saving data? Have you compared your code with a standard example to see if there are any differences?
hello,
Any suggestions?
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,817
Most Valuable Professional
nmaenpaa
101,156