I'm creating a server-side method that sends an email to the Change Leader. It gets invoked "on close" in association with a Change Management workflow activity. The email should be sent only when the activity is closed, and the workflow progresses to the next activity. However, if the user votes on the activity while there are missing affected files related to the Change Management, an error message is displayed stating "The New Number field is required when Action is set to 'Add'." I want to find a way to prevent the email from being sent when such and similar errors exist.
I tried to use
activity.getProperty("state", ""); to check if the state of the activity changes from Active to Closed. However, this property does not update (when the method is invoked) while the mentioned error exists or not.
Currently, I'm thinking of a way to access this error message content from my method and act accordingly. I tried
isError() and it gives 0 (no error),
getErrorDetails() return an empty string.
I would appreciate it a lot if someone can help me with it.