Email Notifications & Flow Designer - Capturing Approval

Tara Bauch
Tera Contributor

I have just recently began exploring using email notifications for approvals with a record producer in Flow Designer in order to integrate some branding and buttons into approvals. My record producer is called Personnel Action Form (PAF) and I have a flow that captures a series of approvals that are accomplished in an "approval" subflow I am building to reuse across the application.  My question is how the actual answer of "approve" or "reject" gets captured to continue the complete the subflow and continue the flow to the next step - the approval gets captured on the approval table via the email notification, but then how do I connect it to the PAF table so that the actual record producer record in the main flow reflects it? 

 

When I run the subflow to test, I get an error that says "Value of Field is not a GlideRecord" (Gliderecord error attachment). So somewhere I'm missing scripting or another step that ties the approval table to the actual PAF record. Any help is appreciated -

 

As an aside, I'm not super experienced with scripting either. 

 

Ask any and all questions as I'm sure I left things out - thanks so much! 

 

 

3 REPLIES 3

Anil Lande
Kilo Patron

Hi,

can you please share your Flow Configurations?

For your information Record producer is just used to insert/create records in target tables. If you have any approvals then you should apply FLOW to the record getting created in your target table. 

In simple word Record producer is just UI form to submit record for end users.

Flow will never run on Record Producer.

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Rajdeep Ganguly
Mega Guru


To capture the approval or rejection from the email notification and reflect it on the PAF table, you need to follow these steps:

1. Create an Approval record: When the flow runs, it should create an approval record in the Approval [sysapproval_approver] table. This record should be associated with the PAF record.

2. Send Email Notification: The email notification should be configured to include the sys_id of the approval record. This can be done by including a direct link to the approval record in the email body.

3. Capture Approval/Rejection: When the user clicks on the approve/reject button in the email, it should redirect them to a UI page where they can approve or reject the request. This UI page should update the approval record based on the user's action.

4. Update PAF Record: Once the approval record is updated, a business rule or script should run on the Approval table to update the PAF record based on the approval status.

Here is a sample script for the business rule:

javascript
(function executeRule(current, previous /*null when async*/) {
//Get the associated PAF record
var paf = new GlideRecord('u_paf');
if (paf.get(current.document_id)) {
//Update the PAF record based on the approval status
if (current.state == 'approved') {
paf.u_approval_status = 'Approved';
} else if (current.state == 'rejected') {
paf.u_approval_status = 'Rejected';
}
paf.update();
}
})(current, previous);


Please replace 'u_paf' and 'u_approval_status' with the actual table name and field name in your instance.

Remember to test this in a sub-production instance first and ensure that it meets your requirements before implementing it in production.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

Hi - thank you for this solution. When should the business rule run? Before, After, async or display?