68) How to filter the record in form using executeQuery

  I had a scenario where I need to Filter the form datable data source when its open :- 


for this 


Step 1 Create a excute query method on the form data source and write the below code :- 

[Form]

public class SupervisedWorkorders extends FormRun

{

    [DataSource]

    class SupervisedWorkorders

    {

        /// <summary>

        ///

        /// </summary>

        public void executeQuery()

        {

            HcmWorkerRecId   worker;


            worker  = HcmWorkerLookup::currentWorker();


            var dataSource = this.query().dataSourceTable(tableNum(AvaSupervisedWorkordersView));


var currentWorkerRange = SysQuery::findOrCreateRange(dataSource,fieldNum(AvaSupervisedWorkordersView, HcmWorker));

            currentWorkerRange.status(RangeStatus::Hidden);;

            currentWorkerRange.value(strFmt('%1', SysQueryRangeUtil::value(worker)));


            super();

        }


    }


}

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++