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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Queries with code x ++

(0) ShareShare
ReportReport
Posted on by

I need a consultation but within the value range not want to be burned or static value, what I want is to grab a value from an external consultation in a method.

This is the code of the queries

public void init()
{
QueryBuildDataSource qbds;

QueryBuildRange qbr;
super();

qbds = this.query().dataSourceTable(tableNum(CustTable));
qbds.clearRanges();
qbr = qbds.addrange(fieldNum(CustTable, MainContactWorker));
qbr.value(queryValue(5637184328));
}

This query is assigned to a role, when validate the query gives me the courage but when I assign the role to the user if not validated me the range value and does not perform the query, and when you burn the value within the range directly if the query is querying me when assigning the user.

I do not understand why, or what I'm doing wrong?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Queries with code x ++

    Hi  Sohaib Cheema

    Please do I should clarify that the query is being carried out by security policies.

    thanks.

  • Sohaib Cheema Profile Picture
    48,522 User Group Leader on at
    RE: Queries with code x ++

    you can use custom code to fix ranges, but to it in that way in init method  you should only initialize query and under executequery of dataset, you can provide value to that range.

    also note that if you are trying to do it on ListPage, you cannot add methods directly on list pages. In such case you have to modify your query which is associated with listpage or you have to add your code in ListPageInteraction Class

    If you have pasted your code in details form such as CustTable, do not expect it to filter ListPage, a Detail page has nothing to do with filtering of its parent form

  • Community Member Profile Picture
    on at
    RE: Queries with code x ++

    Hi André,

    In fact, I'm using custom code into init method for AOT Query to add a range value, do you know if Ax standar support it?.

    Regards,

    Dennis.

  • André Arnaud de Calavon Profile Picture
    298,740 Super User 2025 Season 2 on at
    RE: Queries with code x ++

    Hi Dennis,

    Record level security and eXtensible Data Security does not support x++ queries. AOT queries are the base for XDS. Where did you try to put your custom code?

    5637184328 value is only one record for one person. This is hardcoding and incorrect to use for multiple representatives.

  • Sohaib Cheema Profile Picture
    48,522 User Group Leader on at
    RE: Queries with code x ++

    @Dennis Orellana

    I am sorry to say your English communication is very hard to get.

    its very hard to understand your last reply

  • Community Member Profile Picture
    on at
    RE: Queries with code x ++

    Yes, I didn't read the code carefully, but my point is to avoid using recId value, like 5637184328, in the query range value.

  • Community Member Profile Picture
    on at
    RE: Queries with code x ++

    if it comes from a real-time execution, to make a consult this within a method to know ejecusion user and employee related to that user running and see clients who are in charge of that employee

  • Sohaib Cheema Profile Picture
    48,522 User Group Leader on at
    RE: Queries with code x ++

    using CustTabel.MainContactWorker  cannot benefit here as it will not give any value in current context.

    instead using following statement can give you current worker

    DirPersonUser::currentWorker()

    also make sure that your user should have a relationship with any employee. else current employee will always be zero

    In addition, CustTable must have any record(s) that should match your criteria

  • Community Member Profile Picture
    on at
    RE: Queries with code x ++

    Try use CustTable.MainContactWorker in the range value

  • Sohaib Cheema Profile Picture
    48,522 User Group Leader on at
    RE: Queries with code x ++

    kindly analyze your query on sql server using following query

    select MODELEDQUERYDEBUGINFO,NAME,* from MODELSECPOLRUNTIMEVIEW

    I have doubt on your range.

    did you fixed value of range for actual implementation? or its coming at run-time from somewhere

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans