Monday, March 14, 2022

ListPage Interaction basic class in D365 FO

 class GITS_TicketRequestInteraction extends ListPageInteraction

{

        DAPEmplContract     dapEmplContract,DAPEmplContractlcl;

        DAPTicketRequest    DAPTicketRequestLocal;


        private DAPTicketRequest DAPTicketRequest()

        {

            return this.listPage().activeRecord(queryDatasourceStr(DAPTicketRequestQ, DAPTicketRequest_1)) as DAPTicketRequest;

        }


        public void initializeQuery(Query _query)

        {

            if (this.listPage().listPageArgs().menuItemName() == 'GITS_TicketRequest_ESS')

            {

                _query.dataSourceTable(tableNum(DAPTicketRequest)).addRange(fieldNum(DAPTicketRequest, Worker)).value(int642Str(HcmWorkerLookup::currentWorker()));

                _query.dataSourceTable(tableNum(DAPTicketRequest)).addRange(fieldNum(DAPTicketRequest, Worker)).status(RangeStatus::Locked);

            }

            super(_query);

        }


        public void selectionChanged()

        {

            if(this.listPage().listPageArgs().menuItemName() == 'GITS_TicketRequest_ESS')

            {

                this.listPage().actionPaneControlVisible(formcontrolstr(GITS_TicketRequest, NewButton), false);

            }

            super();

        }


}