Create lookup method for multiple datasource with no direct relation

 Today we have a requiremnt to create look up metho which shows the postion id on the bases of the job . but on the 2 table there is no direct relation so we can see how we join 


1) create a look up method on table level.

2) create a lookup method and pass the refernce on datasource filed level.


1) create a look up method on table level. :- 


 static public void lookupPostionID(FormStringControl _formStringControl, str _jobID)

    {

        

        Query                   query = new Query();


        QueryBuildDataSource    qbds_HcmPostion;

        QueryBuildDataSource    qbds_HcmPositionActionLine;

        QueryBuildDataSource    qbds_HcmPositionActionDetail;

        QueryBuildDataSource    qbds_Hcmjob;


        QueryBuildRange         qbr_Name;

        SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tablenum(HcmPosition), _formStringControl); //EntAssetObjectTable

        

        // initial

        qbds_HcmPostion             = query.addDataSource(tableNum(HcmPosition));


        qbds_HcmPositionActionLine  = qbds_HcmPostion.addDataSource( tableNum(HcmPositionActionLine));

        qbds_HcmPositionActionLine.relations( true);

        qbds_HcmPositionActionLine.fields().dynamic(NoYes::Yes);

        qbds_HcmPositionActionLine.joinMode(JoinMode::InnerJoin);


        qbds_HcmPositionActionDetail = qbds_HcmPositionActionLine.addDataSource( tableNum(HcmPositionActionDetail));

        qbds_HcmPositionActionDetail.relations(false);

        qbds_HcmPositionActionDetail.addLink(fieldNum(HcmPositionActionLine, ActionState), fieldNum(HcmPositionActionDetail, ActionState));

        qbds_HcmPositionActionDetail.fields().dynamic(NoYes::Yes);

        qbds_HcmPositionActionDetail.joinMode(JoinMode::InnerJoin);


        qbds_Hcmjob = qbds_HcmPositionActionDetail.addDataSource( tableNum(HcmJob));

        qbds_Hcmjob.relations( true);

        qbds_Hcmjob.fields().dynamic(NoYes::Yes);

        qbds_Hcmjob.joinMode(JoinMode::InnerJoin);


        qbr_Name = qbds_Hcmjob.addRange(fieldNum(HcmJob, RecId));

        // define query range value

        qbr_Name.value(SysQuery::value(HcmJob::findByJob(_jobID).RecId));


        // perform lookup

        sysTableLookup.addLookupField(fieldNum(HcmPosition, PositionId));

        sysTableLookup.parmQuery(query);

        sysTableLookup.performFormLookup();


    }

=======================================================================

2) create a lookup method and pass the refernce on datasource filed level.


/// <summary>

            ///

            /// </summary>

            /// <param name = "_formControl"></param>

            /// <param name = "_filterStr"></param>

            public void lookup(FormControl _formControl, str _filterStr)

            {

                NGOfferLetterHeader::lookupPostionID(_formControl, HcmJob::find(callerHRMApplication.Job).JobId);

            }



==================xxxxxxxxxxxxxxxxxx=========================


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++