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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Set Dynamic ranges for XDS policy

(1) ShareShare
ReportReport
Posted on by 521
I have a policy with SalesTable as primary table and created a query that has the same table as dataSource.. I didn't set any range in the query, Instead I override the init() method of the query and add my ranges in the code:
[Query]
public class DYNADDVSalesTableQuery extends QueryRun
{
    public void init()
    {
        QueryBuildDataSource qbds;
        QueryBuildRange qbr;

        super();

        qbds = this.query().dataSourceTable(tableNum(SalesTable));
        qbr  = qbds.addRange(fieldNum(SalesTable, SalesId));
        qbr.value('SO-0658823');
    }

}
but it didn't work! How could I make the policy use the query with my dynamic ranges?
I have the same question (0)
  • Waed Ayyad Profile Picture
    9,145 Super User 2026 Season 1 on at
    Hi,

    Can you add more details about your question? 
     
     
    Thanks,
    Waed Ayyad
  • AbdullahAhmed_ Profile Picture
    521 on at
    I hope you could help with this!
  • André Arnaud de Calavon Profile Picture
    305,610 Super User 2026 Season 1 on at
    Hi AbdullahAhmed,

    Can you tell about the exact conditions when a sales order should be visible (or editable) or not for a user? You now added a sales order hard-coded, but I think you can avoid having dynamic ranges using X++ coding, 

    In case you mention that "it didn't work", what is the current behavior? Do you get errors? Did you build the solution and synchronize the database? Also note that in case you have the system administrator role assigned, it will bypass all security, as well as the security policies.
     
    Note that you will not be able to send context to the init method of the query when using XDS. If you have rules and/or conditions, the query should be used to retrieve orders based on access permissions per user.
     
    So, please explain the conditions, then we can help you with a solution direction.
  • AbdullahAhmed_ Profile Picture
    521 on at
    Hii..
    I have a test user that I assign some roles for test and it's not admin at all..
    The scenario is that I have a form that admin can choose which field of sales table to set a range on and provide a value, and I read the field and the value from the related table to the form..
     
     
    I tried the simplest way and add a range in init method with a value but it's not working..
    by saying it's not working I mean the normal behaviour that the user can see all sales orders and I want to restrict this.
  • Verified answer
    André Arnaud de Calavon Profile Picture
    305,610 Super User 2026 Season 1 on at
    Hi AbdullahAhmed,

    The XDS framework is not executing the query. It will be used to get the ranges and possible joins to add to the form data source or any select statement just before trying to retrieve records from the database. So I think the init method will never be executed by XDS. 

    You can create a MyConstruct table, which is temporary table. In this table you can add a XDS method where you can use X++ to fill a temporary table per user. You can look at several tables in the AOT starting with 'My"  (e.g.  MyDepartmerns) to check how to create such table and insert records.
     
    Using X++ you can insert records with a reference to the sales order table to be able to filter the records for the user. 

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 658 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 632 Super User 2026 Season 1

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 570

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans