Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

set deleteallowed option using c/al code

(0) ShareShare
ReportReport
Posted on by

Hi everyone! I need to set the option delete allowed according to the USERID.
My problem is to do this using the code because i don't want to block ALL the users, just a specific understand? My struggle is how to get this page object property in the code..

I want to do something like

IF USERID='john' THEN
PAGE.deleteallowed=FALSE;

I know that PAGE.deleteallowed don't exist but I need something to make this work.

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: set deleteallowed option using c/al code

    Thanks a lot it worked!! :) 

  • Community Member Profile Picture
    on at
    RE: set deleteallowed option using c/al code

    Yes that't my point it's no a simple assignment so i'm a little confused with that answer.. I understand the point but how to validate with the deleteallow itseld?

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: set deleteallowed option using c/al code

    No NAV with me at the moment to check but DeleteAllow property (if I remember correctly) cannot be assigned to a Boolean variable, but it’s only a yes/no option. I suggest to use roles instead (much better and flexible).

  • Community Member Profile Picture
    on at
    RE: set deleteallowed option using c/al code

    So I've created a new variable in table 91 (User setup) as you said and I've add a user and check this field. Now in my page in the property DeleteAllowed I juut have the no/yes option.. I've already add the code in the OpenPage event and get the user logged in.
    I assign DeleteAllowed=No in my page is that? I'm confused sorry.

  • Bodhi Profile Picture
    558 on at
    RE: set deleteallowed option using c/al code

    Sorry for last answer, I should test it first, I messed it 

    Add a field in User setup, XX_DeleteAllowed

    3443.3.PNG

    Under Table Trigger:

    OnDelete()

    UserSetup.GET(uppercase(USERID));
    if not UserSetup.XX_DeleteAllowed then
    error('not allowed table');

    3443.2.PNG

    Test:

    click_5F00_delete_5F00_TableTrigger.PNG

    or Under Page Trigger:

    OnDeleteRecord() : Boolean
    UserSetup.GET(uppercase(USERID));
    if not UserSetup.XX_DeleteAllowed then
    error('not allowed page');

    3443.3.PNG

    Test:

    click_5F00_delete.PNG

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: set deleteallowed option using c/al code

    You cannot do that, this is a property that cannot be modified from C/AL. You can use roles for avoiding the delete option.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans