hello,
I created a multi select lookup using event handlers and I got my output.
I wrote code for one lookup field called custAccount but when I select the drop down CustAccount values are came but also custGroup and name column also came
but i need only custAccount lookup column but automatically custGroup and name colomns are came i need to hide them because it is my requirement.
please help me to sort out this.
below I attached my code for reference.
CODE:
public class AatMultiSelect_Form_Handler
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(SalesTable, CustomerAccount), FormControlEventType::Modified)]
public static void CustomerAccount_OnModified(FormControl sender, FormControlEventArgs e)
{
//FormRun formRun = sender.dataSourceObject().formRun();
FormRun formRun = sender.formRun().dataSource().formRun();
//FormRun formRun = sender.datasource().formRun();
SysLookupMultiSelectCtrl multiSelectCtl = formRun.parmMultiSelectCtl();
SalesTable salesTable = formRun.dataSource(FormDataSourceStr(SalesTable, salesTable)).cursor() as SalesTable;
salesTable.CustAccount = con2Str(multiSelectCtl.getSelectedFieldValues(), ';');
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(SalesTable, CustomerAccount), FormControlEventType::Lookup)]
public static void CustomerAccount_OnLookup(FormControl sender, FormControlEventArgs e)
{
FormStringControl CustomerAccount;
SysLookupMultiSelectCtrl multiSelectCtrl;
FormRun formRun = sender.formRun();
AatMultiSelect_Form_Handler msCtrlClass;
CustomerAccount = sender.formRun().design().controlName(formControlStr(salestable, CustomerAccount));
multiSelectCtrl = SysLookupMultiSelectCtrl::construct(formRun,
CustomerAccount,
queryStr(CustTableSRS),
false,
[tableNum(CustTable), fieldNum(CustTable,AccountNum), false]);
msCtrlClass.parmMultiSelectCtl(multiSelectCtrl);
FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
//cancel super() to prevent error.
ce.CancelSuperCall();
}
public SysLookupMultiSelectCtrl parmMultiSelectCtl(SysLookupMultiSelectCtrl _multiSelectCtrl = multiSelectCtrl)
{
multiSelectCtrl = _multiSelectCtrl;
return multiSelectCtrl;
}
}
thanks,
Aathil Ameen P
Thanks Girish S
Thanks Mohit Rampal. It will helps me.
Hi, Please check this article and instead of using CustTableSRS query, you can create query in code and add only CustAccount field in lookup.
Hi Aathil Ameen,
Account num, Cust Group and Name is shown because in the CustTableSRS query - Datasource >> CustTable >. Under field node you have Account num and Cust Group added >> Inside that DataSource you have DirPartyTable and it is having Name field. So, in the lookup you are seeing all the 3 fields.
To avoid this, you need to duplicate the query and add Only CustTable as DataSource and add CustAccount as only field.
You need to set the Dynamic Fields property to "No" on the DataSource level. Then only you can add your own fields.
Later you can use that query instead of standard one.
Thanks,
Girish S.
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156