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)
Answered

Should the developer call validateWrite/validateDelete?

(0) ShareShare
ReportReport
Posted on by

Hello everybody,

this post is about the developer should always call validateWrite/validateDelete before insert/update/delete-calls in code. We've seen that the AX standard does not call them most of the time.

So maybe you have some hints about callind them or not calling them...

Kind regards

Andi

*This post is locked for comments

I have the same question (0)
  • Verified answer
    MukeshHirwani Profile Picture
    1,180 on at

    Hi,

    Validating records before a CRUD operation is Best Practice that ideally should be followed. Though at various locations in base code MS is even not doing that, but MS works days and night to improve their codebase so might be in the coming builds slowly steadily those issues will be fixed.

  • Pradeep Itnal Profile Picture
    3,248 on at

    sorry ANDIRUDI , MS calls validateWrite and  validatedelete(if required) in most of the cases. :)

    however using validateWrite make sense, to validate a record before its inserted into the table. Calling validateDelete is based on requirement.

    Just curious, can you mention few places, where you feel validate-write should have been called. and had not been called by MS sys layer code.

  • Community Member Profile Picture
    on at

    Hi,

    yes there are a lot of places where there isn't a call to validateWrite (e.g. MarkupTrans, JournalCheckPost, but I haven't checked if there is a need in that special case).

    In general it sounds necessary to validate the records before inserting them, but I don't like the idea auf always having the "if validate then insert" lines in the code. I think this should be done by the insert method itself. Nevertheless it's not a decission of mine so I have to deal with it.

    So that means that we now should always use validateWrite and maybe validateDelete if necessary...!

    (By the way: And what's with modifiedField? Plenty of changes to other fields are done in modifiedField but in the code it never gets called (only in UI)).

    Kind regards

    Andi

  • MukeshHirwani Profile Picture
    1,180 on at

    Hi Andi,

    In some exceptional scenarios there is a need of not calling validateWrite. That's why we need to explicitly do that. I'll say 90% of the cases its required as a BP.

    Modified field, I did not understand ur question exaclty. Though as per my understanding u want to know that from where modifiedField is called.

    Ans. ModifiedField is automatically called if user enters/modifies any value in the field, though If u are manually updating/inserting the record which should actually populate other fields (logic for update is written in modifiedField) then u should manually call modifiedField method and pass the fieldId.

  • Community Member Profile Picture
    on at

    So, just to finish this thread...

    when developing we should always have a look at the modified-Methods of fields we assign values to. If there is actually some code in the modifiedField-method that reacts to the field we're setting we should call that particular modifiedField to ensure that the code gets called.

    In the other direction, if we add some code to the modifiedField-method we should check all cross-references filling the field and maybe add the modifiedField-call if it's not there.

    When inserting/updating/deleting records via code we should call the validateWrite/validateDelete methods in general, but in some cases we may omit them.

    If someone adds code in validateWrite/Delete he has to check crossReferences for all inserts/updates/delets if a validate-call is missing.

    Ist that a good pattern?

    Kind regards

    Andi

  • Xander Vink Profile Picture
    2,550 on at

    [quote]In the other direction, if we add some code to the modifiedField-method we should check all cross-references filling the field and maybe add the modifiedField-call if it's not there.[/quote]

    wouldn't it be a lot easier and less error-prone to just always call the modifiedField method?

  • MukeshHirwani Profile Picture
    1,180 on at

    Yeah... That's the Best Practice :)

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