
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;
}
}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 .