Thursday, June 22, 2017

X++ code for Look up to filter only Global Addresses with respect to Purpose :: Like Delivery Addresses.

Hi Folk's

Recently,I was gone through with an weird requirement to filter the Global Addresses with respect to Purpose :: Like Delivery Addresses.

Note : Here the form control is Reference group.

public Common lookupReference(FormReferenceControl _formReferenceControl)

{

    Query                       query;

    QueryBuildDataSource        qbds,qbds1,qbds2,qbds3;

    QueryBuildRange             qbr;

    SysReferenceTableLookup     sysRefTableLookup;

    LogisticsPostalAddress      logisticsPostalAddress;



    sysRefTableLookup = SysReferenceTableLookup::newParameters(tableNum(LogisticsPostalAddress),_formReferenceControl,true);

    sysRefTableLookup.addLookupfield(fieldNum(logisticsPostalAddress,Address));

    sysRefTableLookup.addLookupMethod(tableMethodStr(logisticsPostalAddress,displayLocationDescription));



    query = new Query();

    qbds  = query.addDataSource(tableNum(LogisticsPostalAddress));

    qbds1 = qbds.addDataSource(tableNum(DirPartyLocation));

    qbds1.joinMode(JoinMode::ExistsJoin);

    qbds1.relations(true);

    qbds1.addLink(fieldnum(DirPartyLocation,location),fieldNum(LogisticsPostalAddress,location));


    qbds2 = qbds1.addDataSource(tableNum(DirPartyLocationRole));

    qbds2.joinMode(JoinMode::ExistsJoin);

    qbds2.relations(true);



    qbds3 = qbds2.addDataSource(tableNum(LogisticsLocationRole)); 

    qbds3.joinMode(JoinMode::ExistsJoin);

    qbds3.relations(true);

    qbr = qbds3.addRange(fieldNum(LogisticsLocationRole,Type));

    qbr.value(enum2str(LogisticsLocationRoleType::Delivery));



    sysRefTableLookup.parmQuery(query);

    logisticsPostalAddress = sysRefTableLookup.performFormLookup();





    return logisticsPostalAddress;

} 

Keep Daxing !!!

No comments:

Post a Comment

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...