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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Lookup using query and ordering by field based on not null and null values

(0) ShareShare
ReportReport
Posted on by 330

Hi,

I have a lookup showing fields vendor account no., name and a custom string field- vendor code.

I want to order by this lookup in ascending order of vendor account number.

But the records having vendor code as not null should appear first in ascending order of vendor code..

And then the records with null values should appear next in ascending order of vendor code.

How can this be done using query object.

Please provide any suggestions.

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    It's an empty string, not null. That's how normal sorting works; I can't think of any way how to achieve your requirement in AX accept having a hidden field (a computed column, most likely) where empty values are replaced with something like 'ZZZZZ' (you should think harder than me about the best value) and sorting by this field.

  • dolee Profile Picture
    11,279 on at

    I agree with Martin.

    Build a view which has a calculated column, that would gives you the desired sorting order. Then base your lookup on that view instead.

  • Yunus Shaik Profile Picture
    330 on at

    Thanks for your replies.

    If I want to just display vendor account number in ascending order first for those records having vendor code as not empty.

    And the remaining records with vendor code as empty should appear after these records in ascending order of vendor account number.

    How can I do this?

    Please give suggestions.

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    It seems just a variant of the previous requirement, therefore the solution would be a variant of the previous suggestion.

  • Yunus Shaik Profile Picture
    330 on at

    Hi Martin,

    Can you please explain how this can be achieved?

  • dolee Profile Picture
    11,279 on at

    Hi Yunus,

    I think the answers Martin and I gave already covered "How [your requirements] can be achieved". What are you looking for?

  • Yunus Shaik Profile Picture
    330 on at

    Hi Dominic,

    I want to display vendor account number in ascending order first for those records having vendor code as not empty.

    And then the remaining records with vendor code as empty should appear after these records in ascending order of vendor account number.

    I don't want to have vendor code ordered.

    Please suggest.

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Generate the hidden sort fields by any logic that meet your requirements. Then just sort by it.

    It's still not clear which part is the problem for you.

  • Yunus Shaik Profile Picture
    330 on at

    I want the lookup to be displayed I following manner.

    Vendor account with Vendor Panel Code first , classified by Vendor Account increasing order, then Vendor account without Vendor Panel Code  , classified by Vendor Account increasing order.

  • dolee Profile Picture
    11,279 on at

    Hi Yunus, if you are looking for code, I suggest you try building it first and let us know if you encounter any error.

    If not, please feel free to let us know what's stopping you from doing it now that you are given the direction. 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans