Update Approval Request allows you to update rejected requests

amadosierra
Kilo Guru

We noticed email responses for approval requests allows you to update records that have already been approved/rejected.

The out-of-the box Inbound Action 'Update Approval Request' does not handle the exception for when a request is already in 'Rejected' state, for example, and the user replies back to the email with the word 'approve' in the subject line. This causes the approval request, that was already in Rejected state, to change to Approved state (something that is not allowed if they access the approval request directly in their browser).

How come this has never been reported nor fixed? Anybody out there is aware of this?

I'll be working on the solution and will post it back once I have it ready.

1 ACCEPTED SOLUTION

JR Asuncion1
Kilo Guru

Hi Amado,



We placed an additional evaluation in the inbound action "Update Approval Request" to catch states that were already valid decisions and send a message back to approver that the approval request has been action-ed.



if (current.state == 'rejected' || current.state == 'approved' || current.state == 'not_required' || current.state == 'cancelled') {


msgArray.push(getApprovalDisplayValue(current));


msgArray.push(current.state.getChoiceValue());


var errorMsg = gs.getMessage("updateError", msgArray);


gs.eventQueue("approval.email.errorMsg", current, email.from, errorMsg);


return;


}



I've also created a UI Message named "updateError", that translates to "The approval state of {0} has already been set to {1}. No action has been taken on this approval.".   Where {0} is the approval number and {1} is the current state.



Hope this helps.



Kind Regards,


JR


View solution in original post

7 REPLIES 7

Hi Jonathan,



We have encountered the same issue as well. I would like to know how you set up your BR to stop email responses that would change the state if the record has already been rejected. Thanks in advance!


JR Asuncion1
Kilo Guru

Hi Amado,



We placed an additional evaluation in the inbound action "Update Approval Request" to catch states that were already valid decisions and send a message back to approver that the approval request has been action-ed.



if (current.state == 'rejected' || current.state == 'approved' || current.state == 'not_required' || current.state == 'cancelled') {


msgArray.push(getApprovalDisplayValue(current));


msgArray.push(current.state.getChoiceValue());


var errorMsg = gs.getMessage("updateError", msgArray);


gs.eventQueue("approval.email.errorMsg", current, email.from, errorMsg);


return;


}



I've also created a UI Message named "updateError", that translates to "The approval state of {0} has already been set to {1}. No action has been taken on this approval.".   Where {0} is the approval number and {1} is the current state.



Hope this helps.



Kind Regards,


JR


Hi,

We are on Madrid version. This doesn't seem to work, meaning if a user sends in an email with "approve" he will get the email in return cause current.state=approved. Does anyone have a nice fix for this that works in Madrid?

 

Cause when I tried this code, if only stopped all rejected and approved emails saying its already approved or rejected (depending on what the incoming mail said). And didn't update the approvals in any way.

Best regards,