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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Lookup method

(0) ShareShare
ReportReport
Posted on by 932

I  add lookup method in form to filter data.

Query query = new Query();
QueryBuildDataSource queryBuildDataSource;

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(SecurityRole), this);
sysTableLookup.addLookupField(fieldNum(SecurityRole,Name));
queryBuildDataSource = query.addDataSource(tableNum(SecurityRole));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

but when I delete role from SecurityRole and I open Form I get the role deleted like this :

0841.role.png

the role "TestRole" doesn't exist in securityRole but I find it in filter :

8345.security.png

How  can I solve this issue?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi, BASMA!

    If you take a look at the Delete button and clicked method on this button you will see what selected role not deleted - it's disabled. Try to add queryRange on IsEnabled field of SecurityRole table.

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi BASMA,

    Are you sure that you deleted it instead of disabling ? Go to AOT and check if it is there under Security\Roles. If it it there and disabled then you need to add range to the query by "IsEnabled" field, because form you referring to does not show disabled roles. 

  • BASMA Profile Picture
    932 on at

    Hi,thanks for reply.

    Yes I find it in AOT\Security\Roles:

    7282.role.png

    But I don't understand your suggestion,How can I add queryRange on IsEnabled field??

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Try this:

    queryBuildDataSource.addRange(fieldNum(SecurityRole, IsEnabled)).value(queryValue(NoYes::Yes));

  • BASMA Profile Picture
    932 on at

    I add this in lookup method but I get error:

    queryBuildDataSource=query.addRange(fieldNum(SecurityRole, IsEnabled)).value(queryValue(NoYes::Yes));

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    It's a wrong code

    queryBuildDataSource=query.addRange(fieldNum(SecurityRole, IsEnabled)).value(queryValue(NoYes::Yes));

    you need this

    queryBuildDataSource.addRange(fieldNum(SecurityRole, IsEnabled)).value(queryValue(NoYes::Yes));

    Range need to be added on DataSource, not on query. 

    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;

    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(SecurityRole), this);
    sysTableLookup.addLookupField(fieldNum(SecurityRole,Name));
    queryBuildDataSource = query.addDataSource(tableNum(SecurityRole));

    queryBuildDataSource.addRange(fieldNum(SecurityRole, IsEnabled)).value(queryValue(NoYes::Yes));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

  • BASMA Profile Picture
    932 on at

    when I add this code I don't get error but in the form I don't get any value in filter

    2055.filter.png

  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Try value("1") instead of value(queryValue(NoYes::Yes))

  • BASMA Profile Picture
    932 on at

    Thanks Rustem.

    It works now :)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans