01 August 2022

Sys operation frame work with example and Multi select lookup using Sys operation frame work service class

This post is to get the sysoperation framework exmaple with the multi select lookup using UI builder class.



 Step1. Create a contract class as follows.

[DataContractAttribute,

SysOperationContractProcessingAttribute(classStr(TRGPlannedPOGroupUIBuilder))]


internal final class TRGPlannedPOGroupContract implements SysOperationValidatable

{

    List saesOrderNumber;


        [DataMemberAttribute("Sales order"),AifCollectionTypeAttribute("Sales order", Types::String),

       SysOperationLabelAttribute(literalStr("Sales order"))]

    public List parmSalesOrder(List _saesOrderNumber = saesOrderNumber)

    {

        saesOrderNumber = _saesOrderNumber;


        return saesOrderNumber;

    }

    public boolean validate()

    {

        boolean             isValid = true;

        List            salesOrderList = new List(Types::String);

        salesOrderList = this.parmSalesOrder();

        if(!salesOrderList.elements())

        {

            isValid = checkFailed("Sales order should not be empty");

        }

        return isValid;

    }

}


Step2: Create the service class.

internal final class TRGPlannedPOGroupService

{

    List salesOrderList;

    public void processGroup(TRGPlannedPOGroupContract _contract)

    {

       ListIterator listIterator;


        listIterator = new ListIterator(_contract.parmSalesOrder());


        while (listIterator.more())

        {

            Info(listIterator.value());

            listIterator.next();

        }

    }

}


Step 3: Create controller class:


class TRGPlannedPOGroupController extends SysOperationServiceController

{

    public static void main(Args _args)

    {

        TRGPlannedPOGroupController controller =

            new TRGPlannedPOGroupController(classStr(TRGPlannedPOGroupService),

            methodStr(TRGPlannedPOGroupService, processGroup),SysOperationExecutionMode::Synchronous);


        TRGPlannedPOGroupContract contract = controller.getDataContractObject();

        //contract.parmArgs(_args);

        controller.startOperation();

    }


    public ClassDescription caption()

    {

        return "Group planned purchase orders";

    }


    public LabelType parmDialogCaption(LabelType _dialogCaption = dialogCaption)

    {

        return "Group planned purchase orders";

    }

}


Step 4: Create UI builder class to get multi slection lookup in the dailog.

internal final class TRGPlannedPOGroupUIBuilder extends SysOperationAutomaticUIBuilder

{

    DialogField     dialogSalesOrder;

    TRGPlannedPOGroupContract plannedPOGroupContract;

    DialogField availableCompanies;

    private void SalesIdLookup(FormStringControl _control)

    {

        Query       query;

        container   conSalesOrder;

        query = new Query(queryStr(SalesTableListPage));

        SysLookupMultiSelectGrid::lookup(query,_control,_control,_control,conSalesOrder);

    }


    public void build()

    {

        int i;

        TRGPlannedPOGroupContract Contract;

        contract = this.dataContractObject() as TRGPlannedPOGroupContract;

        dialogSalesOrder = this.addDialogField(methodStr(TRGPlannedPOGroupContract, parmSalesOrder),contract);

    }


    public void postBuild()

    {

        TRGPlannedPOGroupContract Contract;

        super();

        

        contract = this.dataContractObject() as TRGPlannedPOGroupContract;

        dialogSalesOrder = this.bindInfo().getDialogField(contract, methodStr(TRGPlannedPOGroupContract, parmSalesOrder));

        dialogSalesOrder.lookupButton(FormLookupButton::Always);

    }


    public void postRun()

    {

        Query         query     = new Query();

        QueryBuildDataSource    qbdsLegalEntity     = query.addDataSource(tablenum(SalesTable));

        qbdsLegalEntity.fields().addField(fieldNum(SalesTable, SalesId));

        container selectedFields = [tableNum(SalesTable), fieldNum(SalesTable, SalesId)];

 

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

    }

}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...