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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Dynamic query in XDS policy in D365F&O

(4) ShareShare
ReportReport
Posted on by 1,275
Dear team,
 
Can you please let me know is it possible to use  dynamic query in XDS policy.
 
If yes, please let me know the steps please. As customer has asked to used dynamic query not AOT Query.
 
Thanks in advance.
Categories:
I have the same question (0)
  • Suggested answer
    Sohaib Cheema Profile Picture
    49,434 User Group Leader on at
    Dynamic query in XDS policy in D365F&O
    Yes, it is possible by joining your XDS query to a Table XYZ(which would be your custom table). Table XYZ would also have a form (Form XYZ) that allows you to add or remove values anytime through the front-end UI. This approach makes your XDS query as flexible as you need it to be.
  • CU05031448-0 Profile Picture
    1,275 on at
    Dynamic query in XDS policy in D365F&O
    Thanks Sohaib for the reply.
     
    Can you please provide me the screenshot for better understanding as you suggested.
     
    I have one more query ***
     
    Can I write code like 
    Query build data source to add data source and put range.
     
    Can I use this query in XDS? Is it possible?
     
    Thanks in advance.
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    Dynamic query in XDS policy in D365F&O
    Hi,
     
    What exactly do you mean by "Dynamics query not AOT Query"? XDS can work with AOT Queries only. There is e.g., no option to configure a query and XDS policy from within the application. 

    In case you need a link between e.g. a warehouse and a user, then you will need to have a table where you can setup the link. Anyway, it requires a customization. See also some of the examples I shared on my blog: Extensible Data Security examples for Microsoft Dynamics
  • Sohaib Cheema Profile Picture
    49,434 User Group Leader on at
    Dynamic query in XDS policy in D365F&O
    Regarding your second question: No, you cannot change the queryBuildDataSource or its ranges using X++ at runtime. The query must be defined as a physical AOT query. The only reason the behavior changes is because it’s joined with a custom table, and that custom table enforces the ranges on the query.
    The same custom table is used for the front-end entry (setup). 
     
  • CU05031448-0 Profile Picture
    1,275 on at
    Dynamic query in XDS policy in D365F&O
    Hi Andre, I mean to say customer not want to hardcore the value in query range.
    That's why I am asking about dynamic query.
     
    Is any alternative solution instead of hardcode in AOT Query range?
     
    Kindly elaborate pls.
     
    Thanks in advance 
  • André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    Dynamic query in XDS policy in D365F&O
    Hi,
     
    Thanks for the clarification. Hardcoding should be avoided. That is a fact. Yes, you can do this by having a table in the XDS query taking data from the application that can be managed by a system administrator or super user. This is also what Sohaib and me tried to mention already. 

    The blogs I shared below, provide examples all based on configurable security by e.g. organization assignment, a link between users and warehouses, and some more. 
     
  • CU05031448-0 Profile Picture
    1,275 on at
    Dynamic query in XDS policy in D365F&O
    Hi Andre, thanks for the response.
     
    I go through the blog but sorry not understand fully.
     
    For example - from the CUSTOMER GROUP table I like to put range on query groupid = CG001.
     
    How I can do this approach WITHOUT HARDCODING the value in AOT Query.
     
    Kindly let me know the steps please.
     
    Thanks in advance.
  • CU05031448-0 Profile Picture
    1,275 on at
    Dynamic query in XDS policy in D365F&O
    Kindly reply to me on this pls.
  • Sohaib Cheema Profile Picture
    49,434 User Group Leader on at
    Dynamic query in XDS policy in D365F&O
     
    What does a hard-coded value mean to you?

    In the context of this discussion, a hard-coded value refers to a range that is set directly on the physical AOT query in Visual Studio during development. That’s not what we’re asking you to do.
     
    Instead, we're asking you to join the main table of your XDS policy with a custom table. This custom table would initially be empty. Because of the join between the two tables, the XDS policy will return no records, and nothing will be visible to the user consuming the policy.
     
    Later, if you want to allow this user to see specific data, you can add records to the custom table using the Dynamics front-end UI. This way, the user will begin to see the relevant records based on what's in the custom table.
     
    With that, I’ll leave you with a few questions:
    1) Do you know how to create an XDS policy?
    2) If the answer to the previous question is yes, have you already created or developed an XDS policy?
    3) If the answer to question #2 is yes, please share the details of your XDS implementation.
         -You can show us the full query, including any joins, ranges, etc.
         -Also, please provide the base business requirement in plain business language (no code).
  • CU05031448-0 Profile Picture
    1,275 on at
    Dynamic query in XDS policy in D365F&O
    Dear Sohaib, Sorr, I cannot access of DEV VM now. Unable to send you the screen shot.
     
    I will explain here what i did...
     
    The requirement is--
     
    In the Customer master, we like to see only those records which is created by the specific user only.
     
    So, I have created 
     
    1. Query -  SCA_CustXDS
    Added two data sources:
    Cust Table
    SysUserInfo
    Put the range in SysUserInfo - Id
    Relation - CustTable.createdby == SysUserinfo.id
     
    In the range properties - 
    Field - id
    Staus - locked
    Value - currentUserId
     
    2.Policy - SCA_VendPolicy
     
    Properties - 
     
    Constrained Table - Yes
    Context type - Rolename
    PrimaryTable - CustTable
    Query - SCA_CustXDS
    RoleName - SCA_CustRole
     
    3.Role -  SCA_CustRole
     
    Properties:
    Label - Cust XDS
    Name - SCA_CustRole
     
    Then I will build the DB Sync. It worked fine.
     
    Now I have questions: ****
     
    In the range properties, I have set the value "CurrentuserId" for the ID field.
     
    Is there any other place where I can set the value "CurrentuserId" for Id instead of in AOT Query. This is something hardcoded which I have done.
     
    Hope you understand now.
     
    Waiting for your reply.
     
    Thanks in advance.
     
     
     
     
     
     
     
     
     

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 563 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans