Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

lookup for customer Address

Posted on by 572

Hello Guys,

I have a form where I have the field customer account number. I need to list the cities as a lookup for an another field in the same form. I did below for it. 

public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;

SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(LogisticsPostalAddress), _formControl);
;


qbds= query.addDataSource(tableNum(LogisticsPostalAddress));
qbds.orderMode(OrderMode::GroupBy);
qbds.addGroupByField(fieldnum(LogisticsPostalAddress, City));
qbds.addRange(fieldNum(LogisticsPostalAddress, City),SortOrder::Ascending);
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, City));
sysTableLookup.performFormLookup();
}

Now I need to list only the cities related to that particular customer account number. how can i do it.?

Thanks in advance.  

*This post is locked for comments

  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: lookup for customer Address

    Sorry for the late reply Mr. Rustem, It worked, Thanks a lot

  • Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: lookup for customer Address

    Did you solve the issue?

  • Verified answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: lookup for customer Address

    Try this

        Query                   query = new Query();
        QueryBuildDataSource    qbds, qbds2, qbds3;
        QueryBuildDataSource    QbdsJoin;
        SysTableLookup          sysTableLookup = sysTableLookup::newParameters(tableNum(DirPartyPostalAddressView), _formControl);
        
        qbds = query.addDataSource(tableNum(DirPartyPostalAddressView));
        qbds.addGroupByField(fieldnum(DirPartyPostalAddressView, City));
        qbds.orderMode(OrderMode::GroupBy);
        
        qbds2 = qbds.addDataSource(tableNum(CustTable));
        qbds2.addLink(fieldNum(DirPartyPostalAddressView, Party), fieldNum(CustTable, Party));
        qbds2.joinMode(JoinMode::ExistsJoin);
        qbds2.addRange(fieldNum(CustTable, AccountNum)).value(queryValue("‪‪‪K00001"));
        
        
        sysTableLookup.parmQuery(query);
        sysTableLookup.addLookupfield(fieldNum(DirPartyPostalAddressView, City));
        sysTableLookup.performFormLookup();


  • D365  beginner Profile Picture
    D365 beginner 572 on at
    RE: lookup for customer Address

    Thanks Rustem for the quick response,

    Can you just show me how it should be with above code.

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: lookup for customer Address

    Hi AX Beginner!

    You should use CustTable, DirPartyTable and DirPartyPostalAddressView.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans