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)

Remove case sensitive duplicates from lookup ax 2012

(0) ShareShare
ReportReport
Posted on by

I have a lookup in which I am inserting values on run time, all things are going fine. Requirement is to avoid replicating values if case sensitive. Like ABCD and abcd should not be there in lookup at a time.

Below is my code that I've tried so far.

public void lookup()
{

   Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventJournalTrans), this);

    sysTableLookup.addLookupField(fieldNum(InventJournalTrans,vehicleNo));


    queryBuildDataSource = query.addDataSource(tableNum(InventJournalTrans));
    queryBuildDataSource.addSortField(fieldNum(InventJournalTrans,vehicleNo),SortOrder::Descending);
    queryBuildDataSource.addRange(fieldNum(InventJournalTrans, vehicleNo)).value(SysQuery::valueNotEmptyString());

    sysTableLookup.parmQuery(query);
    QueryBuildDataSource.orderMode(OrderMode::GroupBy);
    sysTableLookup.performFormLookup();



    this.replaceOnLookup();
}

Here is the image of lookup.

enter image description here

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    AX database collation must be set as Case Insensitive, which means if you are grouping by that field, then you will get a single value back if the field contents are the same, but with different case. You will only get a different value, if there are special characters stored in the field such as line break, which is not visible, but would result in 2 entries on a group by due to the different field contents.

    By the way you are missing addGroupByField in your code.

    sohailnedian.blogspot.hu/.../add-group-by-and-fields-selection-in.html

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

    If you say that both ABCD and abcd shouldn't be displayed at a time, doesn't it mean that the case doesn't matter (= case-insensitive)? If so, it's easy, because the database should already be configured as case-insensitive.

    The problem seems to be that you want to group by vehicleNo, but you don't. Use addGroupByField(fieldNum(InventJournalTrans, VehicleNo)) to do it.

  • Community Member Profile Picture
    on at

    Thanks Martin Dráb my code is running well

    thank you soo much :)

  • Community Member Profile Picture
    on at

    thanks

  • Community Member Profile Picture
    on at

    and thank u Vilmos Kintera :)

  • Vilmos Kintera Profile Picture
    46,149 on at

    Please mark helpful answers as Verified to set the topic as resolved.

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