Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Filtering the Location Id(lookup) where the purpose of the location(LocationRole) is 'Service'

(0) ShareShare
ReportReport
Posted on by 3,957

Hi,

I'm trying to filter the LocationId(lookup using query) field where LocationRoles is service.
I've created the following query which filters the LocationId

        Query        query = new Query();
        QueryBuildDataSource    qbds;
        QueryBuildDataSource    qbdsJoin;
        QueryBuildDataSource    qbdsJoin2;
        QueryBuildDataSource    qbdsJoin3;
        QueryBuildDataSource    qbdsJoin4;
        int64 locationroleid = 5637144580;
        SalesTable salestable;
        SysTableLookup          sysTableLookup = sysTableLookup::newParameters( tableNum(LogisticsLocation),sender);
        QueryRun queryrun;
        qbds= query.addDataSource( tableNum(LogisticsLocation));
        qbdsJoin= qbds.addDataSource( tableNum(DirPartyLocation));
        qbdsJoin2= qbdsJoin.addDataSource( tableNum(DirPartyTable));
        qbdsJoin3 = qbdsJoin2.addDataSource( tableNum(CustTable));
        qbdsJoin4  = qbdsJoin.addDataSource( tableNum(DirPartyLocationRole));

        qbdsJoin.relations( true); //If relations are defined in the table then set it to true.
        qbdsJoin2.relations( true);
        qbdsJoin3.relations( true);
             
        qbdsJoin4.relations( true);
                     
        FormRun form = sender.formRun();
        FormDataSource salestable_ds = form.dataSource(formDataSourceStr(SalesTable,SalesTable)) as FormDataSource;
        salestable= salestable_ds.cursor();
            
        sysTableLookup.addLookupfield(fieldNum(LogisticsLocation,LocationId));
        sysTableLookup.addLookupfield(fieldnum(LogisticsLocation,Description));
                  
        qbdsJoin3.addRange(fieldNum(CustTable,AccountNum)).value(queryValue(salestable.CustAccount));
        qbdsJoin4.addRange(fieldNum(DirPartyLocationRole, locationRole)).value(int2Str(locationroleid));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
            

        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
        //cancel super() to prevent error.
        ce.CancelSuperCall();


*This post is locked for comments

  • Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Filtering the Location Id(lookup) where the purpose of the location(LocationRole) is 'Service'

    Instead int2str i tried  using queryvalue(locationroleid) which worked fine. I'll try int642str as well. Thanks :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans