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 :
Microsoft Dynamics AX (Archived)

How to prevent editing records in tables on basis of an enum field in the tale.

(0) ShareShare
ReportReport
Posted on by

I need to prevent modifying certain records in a table. I need to put this condition on the table level, as there are different forms using this table and I cannot put lock on every form. I have an enum field in this table and I need to prevent updating that record if the enum field is populated as 'Yes'.

Please suggest me the code and where I need to add this code.

For Example: I have a customized field in the invent table and I want to prevent editing those records which have this field populated as 'Yes'. I want to prevent this editing at table level itself.

i.e. We should not be able to edit these records from anywhere in ax.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mohsin Khalid Profile Picture
    501 on at

    Hi Hasit ;

    Unfortunately you cannot disable those records from being editable on the form unless you do an allowEdit(false) on the active method of the form or the datasource, However if you simply want to prevent the update from happening from anywhere in AX for those records then override the aosValidateUpdate() method on your table and fail the validation if your enum value is yes, see below code for example.

    public boolean aosValidateUpdate()
    {
        boolean ret;
    
        ret = super();
        
        if (this.EnumField == NoYes::Yes)
            ret = false;
    
        return ret;
    }


    Please note that above code will have a performance impact on update of this table because your flag will be checked for each update.

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    I think better solution is to use XDS, using it you can give view access to certain users to records base on field value. I cannot give you code example because it requires multiple objects to be created, but it's well explained here www.microsoft.com/.../details.aspx

  • Community Member Profile Picture
    on at

    Thanks Mohsin, that was useful.

    I tried your code.

    I found that this is blocking editing on those records which have the enum field as 'yes' and allowing editing those with enum field as 'no' .

    But if I want to change the enum value of one record from no to yes , I am not able to do so (even this is blocked from editing) .Please let me know why I am not able to change the enum value from no to yes and mention the code change I need to do.

  • Verified answer
    Mohsin Khalid Profile Picture
    501 on at

    Yes for that consider adding the below check to the condition. FYI the orig() method returns the value before your mod.

    public boolean aosValidateUpdate()
    {
        boolean ret;
    
        ret = super();
        
        if (this.EnumField == NoYes::Yes && this.orig().EnumFild == noYes::Yes)
            ret = false;
    
        return ret;
    }


  • Community Member Profile Picture
    on at

    Thank you Mohsin, for your timely help.

    You understood my issue perfectly and this solution works as expected.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans