web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / DynamicsAXWorld / Custom Lookup for a dialog ...

Custom Lookup for a dialog field

gangadhar reddy Profile Picture gangadhar reddy 527

This post discusses about creating a custom lookup field on a dialog.
Following are the methods and code required to achieve the purpose.(Assuming the class is extending the RunbaseBatch)

–> A lookup method is required in the first place. Below is the sample code to lookup the exchange rates.
private void exchRate_Lookup(FormStringControl _control)
{
SysTableLookup sysTableLookUp;
QueryBuildDataSource qbds;
Query query = new Query();

qbds = query.addDataSource(tableNum(ExchangeRateType));

sysTableLookUp = SysTableLookup::newParameters(tableNum(ExchangeRateType), _control, true);

sysTableLookUp.addLookupfield(fieldNum(ExchangeRateType, Name));
sysTableLookUp.addLookupfield(fieldNum(ExchangeRateType, Description));

sysTableLookUp.parmQuery(query);
sysTableLookUp.performFormLookup();
}
–> The above method can then be called in the dialog method of the runbase class

public Object dialog()

{

FormStringControl control;

dialog = super();

dlgExcRate = dialog.addField(extendedTypeStr(ExchangeRateTypeName));

control = dlgExcRate.control();

control.registerOverrideMethod(methodstr(FormStringControl, lookUp),methodstr(SampleBatchClass, exchRate_Lookup),this);

return dialog;

}

Note:When we are using this FormStringControl lookup then the batch class “runon” property shouldn’t be “server”

 



This was originally posted here.

Comments

*This post is locked for comments