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)
Answered

ExecuteQuery Method

(0) ShareShare
ReportReport
Posted on by 932

Hi,

I have form that contains 4 datasources like this:

1.UserInfo.

2.SecurityUserRole that has relation with UserInfo:linkType=delayed.

3.SecurityRole that has relation with securityUserRole : LinkType=InnerJoin.

4.EukMatrixRole that has relation with securityRole:linkType=Delayed.

I add executeQuery in SecurityUserRole :

public void executeQuery()
{

this.query().dataSourceTable(tableNum(SecurityUserRole)).addRange(fieldNum(SecurityUserRole, AssignmentStatus)).value(queryValue(RoleAssignmentStatus::Enabled));
this.query().dataSourceTable(tableNum(SecurityRole)).addRange(fieldNum(SecurityRole,Name)).value('!Utilisateur système');//to display roles except UserSystem

super();
}

I add executeQuery in eukMatrixRole :

public void executeQuery()
{

this.query().dataSourceTable(tableNum(EUKMatrixRole)).addRange(fieldNum(EUKMatrixRole,MatrixName)).value(queryValue(SecurityRole.Name));//

super();
}

but when I run the form I don't get the exact values from eukmatrixRole according to the securityRole Name:

matrixRole.png

*This post is locked for comments

I have the same question (0)
  • BASMA Profile Picture
    932 on at

    when I use inner join,I get this :

    8321.role.png


    the roles are repeated 

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

    Hi BASMA!

    If you use addRange() instead of SysQuery::findOrCreateRange() you should call clearRange() before adding a new range.

    Your code there always add a range, therefore if get executed ten times, you create ten ranges for the same field (with the same of different values)

  • BASMA Profile Picture
    932 on at

    Hi Rustem,

    I use clearRange()  in the both datasources?

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

    Yes. But i recommend to use SysQuery::findOrCreateRange().

  • BASMA Profile Picture
    932 on at

    how can I use this instruction?

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

    SysQuery::findOrCreateRange(this.query().dataSourceTable(tablenum(SecurityUserRole)), fieldnum(SecurityUserRole, AssignmentStatus)).value(queryValue(RoleAssignmentStatus::Enabled));

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans