- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 02:52 PM
I have a workflow which creates a catalog task and then in the advanced section of the create task, I programmatically create an approval request for the catalog task using the below code:
var gr=new GlideRecord('sysapproval_approver');
gr.initialize();
gr.sysapproval=workflow.scratchpad.taskid;
gr.approver=current.variables.XXXXCatalogItem_Approver.toString();
gr.state='requested';
gr.insert();
I am trying to create a Notification Rule to send a customised approval notification email to clients when this type of catalog task/approval request is created. Approval rule is as follows:
The problem I have is the above rule is not being triggered when the approval request is created as part of the task. It works fine if I manually create an approval request on the SCTASK after it is created (i.e. just add via the Approvers tab on the catalog task).
I'm thinking the creation by code approach is not triggering an approval.insert event but not sure how to sort that out.
Any assistance would be greatly appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2022 10:20 PM
Just to circle back on this one. ServiceNow support ended up providing the answer. Issue was I was creating sys_approval record as part of the catalog task advanced script. Issue was that the notification rule was being triggered before the task record was created. Needed to add a wait between creating the catalog task and the sys_approval record.
Ended up changing my workflow to be:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2022 10:20 PM
Just to circle back on this one. ServiceNow support ended up providing the answer. Issue was I was creating sys_approval record as part of the catalog task advanced script. Issue was that the notification rule was being triggered before the task record was created. Needed to add a wait between creating the catalog task and the sys_approval record.
Ended up changing my workflow to be: