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 :

How to creating a validate method in the event class in Dynamics 365. #ax #d365

Krishna Bhardwaj Profile Picture Krishna Bhardwaj 97

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;

}

Comments

*This post is locked for comments