Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

sysTableLookup - custom sorting while parmUseLookupValue(true)

Posted on by 65

Hi,

Is there a solution to have custom sort order in sysTableLookup if I want to set parmUseLookupValue(true)? It looks like query sorting is ignored in that case... If I set sysTableLookup.parmUseLookupValue(false) sorting works fine.

public void lookup()
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;

    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(), this);
    
    sysTableLookup.addLookupfield(fieldNum(Table1, DescriptionField), true);
    sysTableLookup.addLookupfield(fieldNum(Table1, SortOrderField));    

    queryBuildDataSource = query.addDataSource(tableNum(Table1));
    queryBuildDataSource.addSortField(fieldNum(Table1, SortOrderField), SortOrder::Ascending);

    sysTableLookup.parmQuery(query);
    sysTableLookup.parmUseLookupValue(true); //same as SysTableLookup::newParameters(tableNum(), this, true)
    sysTableLookup.performFormLookup();
}

  • Suggested answer
    Luke Sha Profile Picture
    Luke Sha on at
    RE: sysTableLookup - custom sorting while parmUseLookupValue(true)

    you're right. Check SysTableLookupBase->formrun method,  once you use parmUseLookupValue(true),  formrun object is initialized in different way. Its datasource will sort by selected field which override your sorted field

  • everand Profile Picture
    everand 65 on at
    RE: sysTableLookup - custom sorting while parmUseLookupValue(true)

    Hi,

    It's a custom table - simple list of strings, just a dozen records (query range and relation to another table doesn't matter - I've delete it).

    Maybe it's important: First time, when the is nothing choosen the sorting works fine. If I choose something from list and again want to change it, now the sorting is by alphabet.

  • Suggested answer
    Luke Sha Profile Picture
    Luke Sha on at
    RE: sysTableLookup - custom sorting while parmUseLookupValue(true)

    Hi

    I cannot reproduce this issue.  Not sure which table referred here. How about adding one new index and using addSortIndex method?

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

Product updates

Dynamics 365 release plans