Thursday, January 30, 2020

D365FO. Dynamics 365 fiance and operation. Get and update contract of batch job on Controller run method. ax 2012

set Batch id in contract if batch isInBatch check is true

in run method we will update the contract and set the batch id.


class BrFunctionalLocationRecordsController extends SysOperationServiceController
{
    protected void new()
    {
        super(classStr(BrFunctionalLocationRecordsService), methodStr(BrFunctionalLocationRecordsService, functionalLocationRecordsService), SysOperationExecutionMode::Synchronous);
    }

 
    public static BrFunctionalLocationRecordsController construct(SysOperationExecutionMode _executionMode = SysOperationExecutionMode::Synchronous)
    {
        BrFunctionalLocationRecordsController      controller;
        controller = new BrFunctionalLocationRecordsController();
        controller.parmExecutionMode(_executionMode);
        return controller;
    }

 
    public static void main(Args _args)
    {
        BrFunctionalLocationRecordsController controller;
        // to update contract value at main we can initialize contract here.
        //BrFunctionalLocationRecordsContract   brFunctionalLocationRecordsContract;

        controller = BrFunctionalLocationRecordsController::construct();
        //and can set contract values here
        //brFunctionalLocationRecordsContract = controller.getDataContractObject();
        controller.parmArgs(_args);
        controller.startOperation();
    }

 
    public ClassDescription defaultCaption()
    {
        return "@Br:FunctionalLocationRecords";
    }

   
    public void run()
    {
        BrFunctionalLocationRecordsContract brFunctionalLocationRecordsContract;

       //getting batch contract.
        brFunctionalLocationRecordsContract = this.getDataContractObject();
       
        Batch                                   batch;
        if (this.isInBatch())
        {
            //getting batch information;
            batch = this.currentBatch;
            //setting batch id in contract
            brFunctionalLocationRecordsContract.parmBatchHeader(batch.BatchJobId);
        }
        super();
    }

}

D365FO. Dynamics 365 fiance and operation. Get and update contract of batch job on Controller run method. ax 2012

set Batch id in contract if batch isInBatch check is true in run method we will update the contract and set the batch id. class BrFunc...