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

Granting and revoking security role permission through X++ code

(1) ShareShare
ReportReport
Posted on by 12
Hi,
 
We have a user who has access rights to create sales order hence his/her security role (let's say it as A) has access Read, Update, Create access   rights. However, it doesn't have 'Delete' rights. That means it cannot delete sales order.
 
Now, We have a SalesCopying screen being used in one of the customization where it creates a return order temporarily and if user clicks on 'Cancel' button on screen, this SalesCopying screen getting closed and that temporarily created Return order gets deleted at the same time.  This works fine for the user who has 'Delete' access rights on SalesTable. but not the above mentioned security role A.  When this user clicks cancel, the SalesCopying screen gets closed, however, it cannot delete that temporary return order  and gets the error message that 'Access denied to table Sales orders (salesTable).'
 
 
Is there any way we can grant the permission through the X++ code for deletion of this temporary return order for this security role and revoke permission after that?
 
That way, the user won't realize that he/she had 'Delete' access rights for the fraction of second and our job will be done too.
 
Anyone faced this before?
 
~ VD
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    307,271 Super User 2026 Season 2 on at
    Hi VD,
     
    Is this SalesCopying screen a standard form or a customization? In case it is a custom feature, you can set the delete action in an "unchecked" block. E.g.:
     
    unchecked(Uncheck::TableSecurityPermission)
    {
        // delete statements here
    }

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 August 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 515 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
CU10121822-0 Profile Picture

CU10121822-0 360

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans