I have an approval process on Case object. Once an approver clicks on Approve button, I have configured a field update approval action, which triggers a Case trigger. This trigger carries out some validations at the backend and throws a validation error on the case object which is under update:
caseObject.addError('Please attach the required files at this stage');
This prevents approval of the case record by throwing an error which looks on the UI as follows:
Now I want some enhancement. I want to make this error look like a Salesforce Validation error. Is there a way I can attach this error to the approval process within apex trigger? I don't want the error to look like the system error as shown in the above screenshot and i perfectly know the reason why it is looking so.
Any help would be appreciated!