Hi, Today I have simple code snippet to create a custom lookup in SSRS Reports in Dynamics 365 for finance and operations.
public class MyUIBuilder extends SrsReportDataContractUIBuilder
{
private DialogField vendordf,dialogbranch;
MyDC contract;
public void postBuild()
{
super();
contract = this.dataContractObject();
// binding dialogs with contract fields
vendordf = this.bindInfo().getDialogField(this.dataContractObject(),
methodStr(MyDC, parmHcmPerfPeriodId));
dialogbranch = this.bindInfo().getDialogField(this.dataContractObject(),
methodStr(MyDC, parmOMOperatingUnitNumber));
dialogbranch.registerOverrideMethod(methodStr(FormStringControl,lookup),methodStr(BEHCMReviewUIBuilder,divisionCodeLookup),this);
vendordf.registerOverrideMethod(methodStr(FormStringControl,lookup),methodStr(BEHCMReviewUIBuilder,PerfPeriodIdLookup),this);
}
public void postRun()
{
}
private void PerfPeriodIdLookup(FormStringControl divisionCodeLookup)
{
Query query = new Query();
QueryBuildDataSource qbd, qbdPerson;
QueryBuildDataSource qbds;
QueryBuildDataSource qbdsJoin;
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(HcmPerfPeriod), divisionCodeLookup);
qbds= query.addDataSource(tableNum(HcmPerfPeriod));
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield(fieldNum(HcmPerfPeriod, PerfPeriodId), true);
sysTableLookup.parmQuery(query);
sysTableLookup.parmUseLookupValue(False);
sysTableLookup.performFormLookup();
}
private void divisionCodeLookup(FormStringControl divisionCodeLookup)
{
Query query;
QueryBuildDataSource qbds,qbds1;
SysTableLookup sysTableLookup;
DimensionAttribute dimAttr;
;
sysTableLookup = SysTableLookup::newParameters(tablenum(OMOperatingUnit),divisionCodeLookup);
sysTableLookup.addLookupfield(fieldnum(OMOperatingUnit, OmoperatingunitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,Name));
query = new Query();
qbds = query.addDataSource(tableNum(OMOperatingUnit));
qbds.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(queryvalue(OMOperatingUnitType::OMDepartment));
sysTableLookup.parmQuery(query);
sysTableLookup.parmUseLookupValue(False);
sysTableLookup.performFormLookup();
}
}