In this post, I'll explain to you how to define or add the lookup method for the Datasource field in the form by using the extension class and method.
Step 1: Go to the Field in the form for which you are willing to add the Custom lookup. Expand the Events Mouse right Click "Copy Event handled Method".
Step 2: Create a new Extension class or Paste the copied method in the new or existing extension class.
The sample code of copied method will look alike.
[FormControlEventHandler(formControlStr(SalesQuotationTable, Line_ItemId), FormControlEventType::Lookup)]
public static void Line_ItemId_OnLookup(FormControl sender, FormControlEventArgs e)
{
}
Step 3: Copy / Type the below code
[FormControlEventHandler(formControlStr(SalesQuotationTable, Line_ItemId), FormControlEventType::Lookup)]
public static void Line_ItemId_OnLookup(FormControl sender, FormControlEventArgs e)
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
SysTableLookup sysTableLookup;
sysTableLookup = SysTableLookup::newParameters(tableNum([TableName]), sender);
queryBuildDataSource = query.addDataSource(tableNum([TableName]));
queryBuildDataSource.addRange(fieldNum([TableName], [FieldName for Filter])).value([Filter field value]);
sysTableLookup.addLookupField(fieldNum([TableName], [FieldName to be selected and shown in lookup]), true);
sysTableLookup.addLookupMethod(tableMethodStr([TableName], [FieldName to shown in Lookup]));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Hope this post will help you to add the Customlookup in Datasource field.
Thanks,
Keep Daxing :)
No comments:
Post a Comment