- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 03:37 PM
Hi team,
On submit, I want to modify the script to add 'Approvers' when automatically creating a Catalog Task. I currently have this code:
Would any of you know how to modify the script to add "Approvers"?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 08:28 AM
You can create approvals via script, but in this case you also want to link the approval to the sc_task record so that it shows on the Related List. Your current script may be creating orphaned approval records, or there could be a Business Rule or Data Policy in place to prevent the insert if not all of the required fields are populated. Here the fields that I have populated when creating approval records via script. I've only ever created approvals at the RITM level - when approval is required before the flow/workflow continues to scripts/Catalog task, etc. but the script should work the same at the Catalog Task level...
var app = new GlideRecord('sysapproval_approver');
app.newRecord(); //newer method than initialize(), but either still works
app.approver = '[sys_id of user]';
app.sysapproval = '[sys_id of sc_task record]';
app.source_table = 'sc_task';
app.document_id = '[sys_id of sc_task record]';
app.state = 'requested';
app.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 08:08 AM
@SooraC - just checking if the code shared by other, working for you or not.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 03:58 PM
Hi @SooraC ,
Please note that the approvals for a catalog items are either on the Request level or RITM level. In both cases, your approvals are automatically added to the related list "approvals" under your Request and RITM form.
If you want to add approvals for catalog item submission, consider reviewing the workflow and add approvals there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 04:46 PM
Thank you so much for your response, @vMalhotra ! Following up with the same question above-
Does this mean that it is not recommended to add "Approvers" to a Catalog Task that is not associated with an RITM? If that's the case, could you clarify why the option to add "Approvers" exists for these tasks?
Currently, we have a flow where Catalog Tasks are created without being linked to an RITM. I am working on writing a script to add "Approvers", but I've been running into some challenges.
I appreciate your insight!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 08:28 AM
You can create approvals via script, but in this case you also want to link the approval to the sc_task record so that it shows on the Related List. Your current script may be creating orphaned approval records, or there could be a Business Rule or Data Policy in place to prevent the insert if not all of the required fields are populated. Here the fields that I have populated when creating approval records via script. I've only ever created approvals at the RITM level - when approval is required before the flow/workflow continues to scripts/Catalog task, etc. but the script should work the same at the Catalog Task level...
var app = new GlideRecord('sysapproval_approver');
app.newRecord(); //newer method than initialize(), but either still works
app.approver = '[sys_id of user]';
app.sysapproval = '[sys_id of sc_task record]';
app.source_table = 'sc_task';
app.document_id = '[sys_id of sc_task record]';
app.state = 'requested';
app.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 07:52 AM
Thank you Brad for your help!