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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

DataEventHandler On validate write syntax

(0) ShareShare
ReportReport
Posted on by 87

I need  help with event handler syntax 

more details:

when I copy even handler method from the events in the table this code showing but I can't understand and use it.

[DataEventHandler(tableStr(WMSBillOfLadingOrder), DataEventType::ValidatedWrite)]
public static void WMSBillOfLadingOrder_onValidatedWrite(Common sender, DataEventArgs e)
{
WMSBillOfLadingOrder WMSBillOfLadingOrder = sender as WMSBillOfLadingOrder;
boolean result = validateArgs.parmValidateResult();
ValidateEventArgs validateArgs = e as ValidateEventArgs;

}

I need to know how to write code validatewrite and convert this code for validateWrite.

↓↓↓↓↓↓↓↓


[Extensionof(tableStr(WMSBillOfLadingOrder))]

final class Training_WMSBillOfLadingOrder_Table_Extension

{




    public void modifiedField(FieldId _fieldId)
    {
        


        next modifiedField(_fieldId);

 

        switch (_fieldId)
        {
            case fieldNum(WMSBillOfLadingOrder, grossWeight):
            case fieldNum(WMSBillOfLadingOrder, tareWeight):
                this.calculateWeight();
                break;
        }
    }

    void calculateWeight()
    {
          this.validateWrite();
          
        
        
    }

    boolean validateWrite()
    {
        boolean ret= next validateWrite();

        if(ret && this.grossWeight < this.tareWeight)
        {
            ret = checkFailed("Gross Weight should be reereerr or equal to Tare Weight");
        }
        else{
        this.weight = this.grossWeight - this.tareWeight;
        }

        return ret;

    }

}

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Hi pavilionit,

    first of all, let me emphasize one more time that you should not update any values in validateWrite. It's not intended to be used like that. And how can you trust the validations if the validation itself might update the data after parts of it are validated? We discussed it already here: community.dynamics.com/.../dataeventhandler-on-validate-write

    Second, I see you selected many tags for your question - are you sure that they're relevant to your question? Please choose only tags that are relevant to your question.

    About the actual question - I tried to search the web to find help for you. I typed following terms in web search: "dynamics 365 operations onvalidatedwrite example" and found a lot of examples. Here's one: d365solution.blogspot.com/.../validatedwrite-eventhandler-d365-at.html .

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans