Hi guys, Today we see how to ADD Lookup, Disable Dialog field using UI builder in D365FO/Ax7.
UiBuilder Class:
class PriceDiscUiBuilder extends SysOperationAutomaticUIBuilder //SrsReportDataContractUIBuilder
{
PriceDiscDataContract priceDiscDataContract;
Public void build()
{
priceDiscDataContract = this.dataContractObject();
this.addDialogField(methodStr(PriceDiscDataContract, parmPriceDiscJournalNum), priceDiscDataContract).allowEdit(false);// Disable the field
this.addDialogField(methodStr(PriceDiscDataContract, parmPostedPriceDiscJournalNum ), priceDiscDataContract);
}
Public void lookupPostJour(FormStringControl _formStringControl)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildRange qbr;
SysTableLookup lookup;
lookup = SysTableLookup::newParameters(tableNum(PriceDiscAdmTable), _formStringControl);
qbds=query.addDataSource(tableNum(PriceDiscAdmTable));
qbr=qbds.addRange(fieldNum(PriceDiscAdmTable, Posted));
qbr.value(SysQuery::value(NoYes::Yes));
lookup.parmQuery(query);
lookup.addLookupfield(fieldNum(PriceDiscAdmTable, JournalNum));
lookup.addLookupfield(fieldNum(PriceDiscAdmTable, JournalName));
lookup.performFormLookup();
}
Public void PostBuild()
{
DialogField postedJourNum;
postedJourNum=this.bindInfo().getDialogField(this.dataContractObject(),
methodStr(PriceDiscDataContract,parmPostedPriceDiscJournalNum));
postedJourNum.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(PriceDiscUiBuilder, lookupPostJour), this);
}
}
Contract Class:
[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(PricediscUiBuilder))]
public class PriceDiscDataContract
{
str priceDiscJournalNum;
PriceDiscJournalNum postedPriceDiscJournalNum;
[DataMemberAttribute,
sysoperationh('Current journal number'),
SysOperationHelpTextAttribute('Enter journal number')]
//SysOperationControlVisibilityAttribute(false)// Hide control
public str parmPriceDiscJournalNum(str _priceDiscJournalNum = priceDiscJournalNum)
{
priceDiscJournalNum = _priceDiscJournalNum;
return priceDiscJournalNum;
}
[DataMemberAttribute,
SysOperationLabelAttribute('Posted journal number'),
SysOperationHelpTextAttribute('Enter journal number')]
public PriceDiscJournalNum parmPostedPriceDiscJournalNum(PriceDiscJournalNum _priceDiscJournalNum = postedPriceDiscJournalNum)
{
postedPriceDiscJournalNum = _priceDiscJournalNum;
return postedPriceDiscJournalNum;
}
}
OutPut:
Keep Daxing!!