Skip to main content



No record found.

Project Operations forum

Filter Lookup in BatchJob in UI Builder class using SysOperation framework using x++ in d365fo

Posted on by 140

I have created a BatchJob using SysOperation Framework for Eliminate Estimate as like standard BatchJob (Project Management & Accounting -> Inquries -> Eliminate Estimate)

but in this Custom BatchJob I have written code for multiselection Lookup in UI Builder class and use ListEnumerator to brings the Multiple RecId.

I followed this below link to create the BatchJob using SysOperation Framework

UI Builder Class :

public class HEX_EliminateEstimateUIBuilder  extends SysOperationAutomaticUIBuilder
    SysLookupMultiSelectCtrl         ctrlProjId;
    DialogField                      displayProjId;
    HEX_EliminateEstimateContract    contract;

    protected DialogField addDialogField(IdentifierName _methodName, Object _dataContract = this.dataContractObject())
        DialogField dialogField;;

        switch (_methodName)
            case methodStr(HEX_EliminateEstimateContract, parmProjId):
                displayProjId = this.dialog().addField(extendedTypeStr(ProjWipId));
                dialogField = displayProjId;
                dialogField = super(_methodName, _dataContract);
        return dialogField;

    public void postRun()
        if (this.dataContractObject() is HEX_EliminateEstimateContract)     

    protected void lookupProjId()
        Query                   query               = new Query();
        QueryBuildDataSource    qbds                = query.addDataSource(tableNum( ProjControlPeriodTable));
        AssetTable              assetTable;

        qbds.addRange(fieldNum(ProjControlPeriodTable, PeriodStatus)).value(SysQuery::value(ProjControlPeriodStatus::Posted));
        qbds.addSelectionField(fieldNum(ProjControlPeriodTable, ProjId));               
        qbds.addSelectionField(fieldNum(ProjControlPeriodTable, PeriodStatus));

        container selectedFields = [tableNum( ProjControlPeriodTable), fieldNum(ProjControlPeriodTable, ProjId)];    

        ctrlProjId = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), displayProjId.control(), query, false, selectedFields);

    public void getFromDialog()
        if (this.dataContractObject() is HEX_EliminateEstimateContract)
            List        listProjId  = new List(Types::String);
            container   conProjId   = ctrlProjId.get();
            int         i = 1;
            Counter conCount = 1;
            Counter conIdLength = conLen(conProjId);

            for(i = 1; i<= conIdLength; i  )
                listProjId.addEnd(any2Str(conPeek(conProjId, i)));




According the UI Builder Class it allow me to select multiple records for those record which is in Posted Status , but need to filter also these ranges.

As standard in ProjControlPeriodTable , for same ProjId there are multiple RecId ,

Let suppose we have one projId (_ITSProj1) for this projId we have three different recid , and all these three ProjId have a Posted Status as per the query range.
But in standard feature there is one method in table which is ProjcontrolPeriodTable.allowEliminate() which brings those record to whom the Eliminate button will be enable in ProjconrolPeriod form , so I need to use this method in query range , that the range will be filtered accordingly and brings only the record to whom the button will be enable as standard.

The requirement is to create batchjob for eliminate estimate with multiple selection with filtered Posted Status and brings only those record for that the standard "Eliminate" button will be enable.

Can please suggest me how Can i filtered to use this allowEliminate() method .

allow eliminate I

allowEliminate() II

this images is showing standard method in ProjControlPeriodTable Table , and accordingly this method , the standard button is enable and In the custom batchjob , in query section need this method to follow.

Please suggest me the solution.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans