Send Reject Reason to Requestor

alexcharleswort
Tera Expert

Right now, what I have working is when a request is rejected by the approver, the workflow pushes out a notification to contact the admin of that process. This is helpful, but I would really like to add the reject reason to the message of the notification that is already being pushed out.

So the process going right now is pretty typical where the approve or reject email is sent to the approver and then they click reject, spawning a reply:
reject email.PNG

So, on the notification that goes out on the workflow, I want it to say something like "your request was rejected. Please contact Tina if you have any questions" followed by the reject reason (in this case "please correct dates").

Any ideas on how to get this inbound email to copy and paste to the notification?

1 ACCEPTED SOLUTION

So this is actually composed of 3 parts for us as we have approvals at both the sc_request and sc_req_item levels.



1. Use a business rule to fire the correct events ( we are doing this so that we can notify the sysapproval.request.requested_for which is not an available field from the notifications)



SS092.bmp



Script:


function onBefore(current, previous) {


  //This function will be automatically called when this rule is processed.


  if(current.source_table == 'sc_request') {


      if(current.state == 'approved') {


          //gs.log('current.source_table/action: sc_request/approved');


          gs.eventQueue("approval.req_approved", current, current.sysapproval.requested_for.sys_id, current.sysapproval.requested_for.name);


      } else if(current.state == 'rejected') {


          //gs.log('current.source_table/action: sc_request/rejected');


          gs.eventQueue("approval.req_rejected", current, current.sysapproval.requested_for.sys_id, current.sysapproval.requested_for.name);


      }


  } else if (current.source_table == 'sc_req_item') {


      if(current.state == 'approved') {


          //gs.log('current.source_table/action: sc_req_item/approved');


          gs.eventQueue("approval.ritm_approved", current, current.sysapproval.u_requested_for.sys_id, current.sysapproval.u_requested_for.name);


      } else if(current.state == 'rejected') {


          //gs.log('current.source_table/action: sc_req_item/rejected');


          gs.eventQueue("approval.ritm_rejected", current, current.sysapproval.u_requested_for.sys_id, current.sysapproval.u_requested_for.name);


      }


  }


}



2. Configure each of the notifications


SS094.bmp


SS096.bmp


3. (Optional) we use mail scripts to format our email notifications into a basic template that is consistent across the board. Ours look like the below


SS099.bmp


View solution in original post

7 REPLIES 7

So this is actually composed of 3 parts for us as we have approvals at both the sc_request and sc_req_item levels.



1. Use a business rule to fire the correct events ( we are doing this so that we can notify the sysapproval.request.requested_for which is not an available field from the notifications)



SS092.bmp



Script:


function onBefore(current, previous) {


  //This function will be automatically called when this rule is processed.


  if(current.source_table == 'sc_request') {


      if(current.state == 'approved') {


          //gs.log('current.source_table/action: sc_request/approved');


          gs.eventQueue("approval.req_approved", current, current.sysapproval.requested_for.sys_id, current.sysapproval.requested_for.name);


      } else if(current.state == 'rejected') {


          //gs.log('current.source_table/action: sc_request/rejected');


          gs.eventQueue("approval.req_rejected", current, current.sysapproval.requested_for.sys_id, current.sysapproval.requested_for.name);


      }


  } else if (current.source_table == 'sc_req_item') {


      if(current.state == 'approved') {


          //gs.log('current.source_table/action: sc_req_item/approved');


          gs.eventQueue("approval.ritm_approved", current, current.sysapproval.u_requested_for.sys_id, current.sysapproval.u_requested_for.name);


      } else if(current.state == 'rejected') {


          //gs.log('current.source_table/action: sc_req_item/rejected');


          gs.eventQueue("approval.ritm_rejected", current, current.sysapproval.u_requested_for.sys_id, current.sysapproval.u_requested_for.name);


      }


  }


}



2. Configure each of the notifications


SS094.bmp


SS096.bmp


3. (Optional) we use mail scripts to format our email notifications into a basic template that is consistent across the board. Ours look like the below


SS099.bmp


That was SUPER helpful! the business rule is what was wrong! I was trying to do it all on the notification so it was all going nowhere.


You are awesome! Thank you!


Hi,



The same as above only difference is when sme one rejects the SR it shld show the single txt field which shld say enter the rejection reason.



Kindly help.



Regards,


Shristy Agrawal