web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

lookup based on selection of another field.

(0) ShareShare
ReportReport
Posted on by 371

i have created one simple form in that i take the site id from the invent site my question is that if i select the site id 1 the another look up show all the site instead of 1..or if i select the site id 2 it show all the site except 2....

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    306,118 Super User 2026 Season 1 on at

    Hi Vinay,

    In this case you need to create a custom lookup where you can specify your filters. However you selected the current version, which is D365 for Operations (aka AX7), the documentation from AX2012 should also help you: msdn.microsoft.com/.../hh185372.aspx

  • CU02060633-1 Profile Picture
    371 on at

    thanx @André Arnaud de Calavon...in the form from site is the EDT and to site is the string filed i tried to filter on the bases of from site but it not filters

    the code is

    public void lookup()

    {

       Query                   query = new Query();

       QueryBuildDataSource    queryBuildDataSource;

       QueryBuildRange         queryBuildRange;

       SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tableNum(InventSite), this);

       sysTableLookup.addLookupField(fieldNum(InventSite, siteid));

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

       queryBuildRange = queryBuildDataSource.addRange(fieldNum(InventSite, siteid));

       queryBuildRange.value(queryValue(AMYinventsiteFromSite.text()));

       sysTableLookup.parmQuery(query);

       sysTableLookup.performFormLookup();

    }

    the code is doing that if i select the 1 then the to site also showing the 1

  • Suggested answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi Vinay,

         sysTableLookup.addLookupField(fieldNum(InventSite, siteid),true);

  • Verified answer
    MUHAMMAD HAARIS Profile Picture
    770 on at

    Hi Vinay Tak,

    You have given the same site as range, so you get same site in your lookup. If you select the range is not as your selected Site means, you have to give like this

    queryBuildRange.value(SysQuery::valueNot(AMYinventsiteFromSite.text()));

  • CU02060633-1 Profile Picture
    371 on at

    @Muhammad Haaris ..owsome..this works thans a lottt....can you help me one more thing is that

    if i select the from site 1 and to site 2..then ok it saves in table and next time when i select from site 1 to site 2 it throw error record already exist

  • MUHAMMAD HAARIS Profile Picture
    770 on at

    Hi Vinay Tak,

    Check the index Property in your table whether the InventSiteId added and may be allow duplicates sets true.

  • CU02060633-1 Profile Picture
    371 on at

    @Muhammad Haaris...i donot want to use index because from site 1 and to site is 2 then save when the net time user select the from site 2 and to site 2 it throws the error already exist but i have to make validate for the 1 when the from site change it should make the record

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sanhthosh.Kumar.K Profile Picture

Sanhthosh.Kumar.K 2

#2
Raed Salah Bzour Profile Picture

Raed Salah Bzour 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans