Validation on click of approve

Hi Community,

 

I wanted to implement a funtionality where a validation should happen on click of Approve button. If the valiation fails the approval should not happen.

 

To achive the above task I tried with the following approaches, on the "UsrReturns" custom object.

  1. Tried to implement "asyncValidate" on "UsrReturnsVisaPageV2", but it didn't work (Seems the approval is happening outside the context of this page). Also not sure what is the use of this page.
  2. Tried to implement validation using Entity Events Layer on the object "UsrReturnsVisa". Although it didn't approve the request, but it didn't throw the exception as well with the following code,
    if(true){
    	throw new Exception("Can not approve");
    }
    return true;
  3. Tried to implement a custom approval logic using "ApprovalDashboardItemViewModel", but I can not create a replacing schema with this.

So need a way to implement such funtionality. Any suggestions will help.

 

Thanks & Regards,

Sourav Kumar Samal

Like 0

Like

3 comments

Hello,

 

Can you please screenshot the exact button you click, clicking which should start the validation process?

 

Thank you!

 

Best regards,

Oscar

Oscar Dylan,

While clicking Approve on notification panel as shown below,

 

 

Also while clicking under DCM & from Approvals section, same error shows on the console, but popup doesn't come.

 

Regards,

Sourav

Sourav Kumar Samal,

 

this is a bad request response returned by the app and we need to see the actual response (from the "Response" tab of the request in the "Network" tab).

 

To add some logic upon approval you need to replace the "approve" method in the "VisaNotificationsSchema" module (for "reject" actions its "reject" method). You will be in the context of the approval record and you can use data from there to process further with the approval\rejection. So you need to override the logic of these two methods.

 

Best regards,

Oscar

Show all comments