How to creating a validate method in the event class in Dynamics 365. #ax #d365
Here I'm going to show you how we can create a validate method in an event handler class and call this function when an event occurs.
So it's my handler class, and I created the OnClicking event for the Ok button and a static validate method for validating the conditions. You'll get an error message whenever validateAttributes() method returns false.
[FormControlEventHandler(formControlStr(JmgProductionFloorExecutionReportProgress, OKButton), FormControlEventType::Clicking)]
public static void OKButton_OnClicking(FormControl sender, FormControlEventArgs e)
{
if(!JmgProductionFloorExecutionReportProgressFormHandler::validateAttributes())
{
throw Error ('Error occurs');
}
}
public static boolean validateAttributes()
{
boolean ret;
ret = true;
//Your condition
if(...)
{
ret = false;
}
return ret;
}

Like
Report
*This post is locked for comments