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)

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)
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    This query is assigned to a role,

    How a query is assigned to role? Are you refereeing to security policy or record level security or something else?

     

    Kindly try to explain in normal wording and more details what you want to have

  • Community Member Profile Picture
    on at

    correct the query is assigned a role and this can be by record-level security or security policies does not matter. I need you to validate the value to the range of the query. that when I assign him the role does not perform the query.

  • Community Member Profile Picture
    on at

    the query will be assigned to a role that is a sales representative and the representative has access only to its client list, not the entire list of customers.

  • Community Member Profile Picture
    on at

    where does the query range value 5637184328 comes from? You may need to replace it with table.field

  • Community Member Profile Picture
    on at

    5637184328 value is extracted from MainContactWorker CustTable field of this table relates to the table with the RECID HcmWorker field.

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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

  • Community Member Profile Picture
    on at

    Try use CustTable.MainContactWorker in the range value

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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

    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

  • Community Member Profile Picture
    on at

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

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