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 :
Finance | Project Operations, Human Resources, ...
Unanswered

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

(0) ShareShare
ReportReport
Posted on by 150

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 

https://ariste.info/en/2020/01/add-multi-selection-lookup-to-a-sysoperation-framework-dialog/

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;
                break;
            default:
                dialogField = super(_methodName, _dataContract);
        }
        return dialogField;
    }

    public void postRun()
    {
        super();
        if (this.dataContractObject() is HEX_EliminateEstimateContract)     
        {
            this.lookupProjId();
        }
    }

    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()
    {
        super();
        
        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)));
                  }
           
            this.dataContractObject().parmProjId(listProjId);

           
        }
    }

   

}

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.

I have the same question (1)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 724 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 580 Most Valuable Professional

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 554

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans