Issue firing Events/Notifications based on the Approval table from Workflow

steve_au
Kilo Contributor

Hi all,

I have a 'request - approve - fulfill' custom app based on a custom request table(extending task) and I have created a workflow to handle the approval component.

The approver receives a notification on request creation. To achieve this in the workflow I create an 'approval - user' and an external event and notification(based on Approval table) to fire on insert of a new approval record for my app.

I've created buttons on the email notification to allow the approver to approve/reject by inbound mail action. This works fine.  

After a given time period of inaction (using a workflow timer) I send the approver a reminder notification. I create a separate event and notification for the reminder based on the approval table and then fire the event using 'Create Event' in the workflow.

My problem is... Because the workflow is firing the reminder event, it seems the event and associated notification are identified as based on my request table and not the Approval table. As a result, I'm not able to use the inbound action to allow direct interaction with the approval via the notification.

I hope that makes sense.

BTW still on Fuji, upgrading soon.

Any assistance would be greatly appreciated.

thanks

Steve

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Steve,



What about this... rather than the workflow firing the event directly, use a Run Script activity to find the approval related to your request, retrieve that record with a GlideRecord query, and fire the event (passing the approval GlideRecord instead of current in the second parameter.)? Your event and notification will be tied to the sysapproval_approver table.



While not an exact script, this should get you started... (change the event name and parameters as appropriate.)



triggerApprovalNotification();



function triggerApprovalNotification() {


        var approval = new GlideRecord('sysapproval_appover');


        approval.addQuery('sysapproval', current.getValue('sys_id');


        approval.query();



        while (approval.next()) {


                  gs.eventQueue('approval.reminder', approval, 'parm1', 'parm2');


        }


}


View solution in original post

5 REPLIES 5

Chuck Tomasi
Tera Patron

Hi Steve,



What about this... rather than the workflow firing the event directly, use a Run Script activity to find the approval related to your request, retrieve that record with a GlideRecord query, and fire the event (passing the approval GlideRecord instead of current in the second parameter.)? Your event and notification will be tied to the sysapproval_approver table.



While not an exact script, this should get you started... (change the event name and parameters as appropriate.)



triggerApprovalNotification();



function triggerApprovalNotification() {


        var approval = new GlideRecord('sysapproval_appover');


        approval.addQuery('sysapproval', current.getValue('sys_id');


        approval.query();



        while (approval.next()) {


                  gs.eventQueue('approval.reminder', approval, 'parm1', 'parm2');


        }


}


Thanks Chuck, you are a genius!


keithl22
ServiceNow Employee
ServiceNow Employee

How did you end up getting this working? I have a similar need, but I can't find the right place in the workflow to place the Run Script activity. Placing it before the Approval User step causes it to fail because there are no current approvals in the system and placing it after approval user step fails because the approval is already completed (or rejected). I also tried doing an advanced Approval User step and used the script there, which sort of worked, but the event still triggered from the table the workflow is built on and not the sysapproval table.   

Kushal9
Mega Contributor

Hey Chuck,

 

Working on the same scenario and did what you have suggested but event is still getting trigger from the table the workflow is built on i.e RITM.