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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

XDS policy used in x++ in D365FO

(2) ShareShare
ReportReport
Posted on by 1,056

Hi team,

I have implemented XDS policy based on custom table and it's perfectly worked when i assigned the specific role to the user. 

Here my question is, can we use XDS policy through x++? Is it possible?

Pls advise, thanks 

Categories:
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    307,157 Super User 2026 Season 2 on at

    Hi,

     

    Can you tell us what would be the scenario to use it with X++? There can be two scenarios. 

    The first scenario is bypassing XDS in coding to read all records from your table despite an active security policy. E.g.

    unchecked(Uncheck::XDS)

    {

        CustomTable    customTable;
        

        while select customTable

        {

            //do something

        }

    }

    Within the unchecked part, the XDS policy is not active.

     

    The second use case is to enable a context string property on the XDS policy. You can manage with the XDSServices class if XDS is active or not in X++. See two examples below. The first example is changing the current context string. The other is activating and deactivating the XDS policy.

     

  • CU10121822-0 Profile Picture
    1,056 on at

    Thanks Andrea for the response.

    Could you please let me know when we go for x++ to used xds policy for both active or inactive 

    Inactive i understood, whenever we like to bypass the xds policy through code we should use unchecked(uncheck::XDS).

    Kindly elaborate about enable xds through x++.

    My question is, when we think about to go x++ for xds policy. Still not understand 

    Pls advise, thanks 

  • André Arnaud de Calavon Profile Picture
    307,157 Super User 2026 Season 2 on at

    Hi,

     

    Initially, when there is a need to secure records, the policy should be active. In some exceptions, you might need to loop through all records for a specific task. 

    Microsoft used bypassing of XDS when initializing MyConstruct tables where specific records are stored within the session which are allowed to be seen by the user. You can check the places in the standard application where the unchecked statement or XDSServices class is used to learn from the examples. 

    I used the unchecked several times to process all records in the background which were not visible to the end-user on the form.  

  • CU10121822-0 Profile Picture
    1,056 on at

    Sorry not understand 

  • André Arnaud de Calavon Profile Picture
    307,157 Super User 2026 Season 2 on at

    Can you please tell what exact part you don't understand?

  • CU10121822-0 Profile Picture
    1,056 on at

    XDS active with x++. Could you please provide me an example 

     

  • Suggested answer
    CU-1234529-002 Profile Picture
    368 on at

    Hi @CU10121822-0

    Yes, XDS (Extensible Data Security) is used to implement row-level data security in D365FO. When an XDS policy is active, it restricts the records that a user can access based on the policy query and security context.

    If there is a specific requirement to process records that are normally restricted by the XDS policy, XDS can be bypassed from X++ using the unchecked statement. For example:
    unchecked
    {
         While Select myTable
         {
              //Process all requried records
         }

    This allows the code to access records without the normal XDS restrictions for that operation.

    You can also refer to standard application examples where the unchecked statement or XDSServices class is used to bypass XDS restrictions.

    However, this should be used carefully, as it bypasses the row-level data security provided by XDS and should only be done when there is a valid business or technical requirement.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    307,157 Super User 2026 Season 2 on at

    Hi,

    Let me give an example of a policy we used in the past. We wanted to restrict the view on workers for people to see only their own team. The HCMWorker table was constrained. We did this by using a temporary table with a XDS() method to fill values of workers allowed to view. This is a so calles MyConstruct table. You can find examples in the standard application with tables such as MyDepartments. They all start with ‘My’.

    The XDS method was checking the HCMWorkers table to have some references inserted in the temporary table, e.g. MyTeamMembers. As the policy was active, no records could be read. So in the XDS method, the unchecked statement can be used to bypass the security policy at this stage.
    Hope this helps. You can check standard security policies to learn the framework. You can also check out the examples I provided on my blog: Extensible Data Security examples for Microsoft Dynamics

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 426 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 358

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 353 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans