Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

ExecuteQuery Method

Posted on by 920

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

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: ExecuteQuery Method

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

  • BASMA Profile Picture
    BASMA 920 on at
    RE: ExecuteQuery Method

    how can I use this instruction?

  • Verified answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: ExecuteQuery Method

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

  • BASMA Profile Picture
    BASMA 920 on at
    RE: ExecuteQuery Method

    Hi Rustem,

    I use clearRange()  in the both datasources?

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: ExecuteQuery Method

    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
    BASMA 920 on at
    RE: ExecuteQuery Method

    when I use inner join,I get this :

    8321.role.png


    the roles are repeated 

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans