Wednesday, April 22, 2020

Add Custom lookup on EP

The trick is to override datasetLookup() on Dataset > data source > field > methods. You will not find this method in the list of override methods so just create this as new method.
the table which we are using for lookup should be in the Dataset

public void dataSetLookup(SysDataSetLookup sysDataSetLookup)
{
    List list = new List(Types::String);

    Query query = new Query();

    QueryBuildDataSource    queryBuildDataSource;

    QueryBuildRange qbr;

    // Add the table to the query.

    queryBuildDataSource  = query.addDataSource(tableNum(HcmWorker));

    //add the range

    qbr = queryBuildDataSource.addRange( fieldnum(HcmWorker, PersonnelNumber));

   // qbr.value(DirPersonUser::currentWorkerPersonnelNumber());

   // qbr.status(RangeStatus::Locked);

     // Specify the fields to use for the lookup.

    list.addEnd(fieldStr(HcmWorker,PersonnelNumber));

    list.addEnd(fieldStr(HcmWorker,Name()));


     sysDataSetLookup.parmLookupFields(list);

     // Specify the field that is returned from the lookup.

    sysDataSetLookup.parmSelectField('PersonnelNumber');

     // Pass the query to the SysDataSetLookup so that the query is used.

    sysDataSetLookup.parmQuery(query);
 
}

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8