Approval in Catalog task Level

kesavanavya
Tera Contributor

I need a approval in catalog task not in RITM level and task should closed only after at least one approval got approved.
i tried with a script below in the workflow catalog task activity

var sysid = task.sys_id;
var taskSysID = task.setNewGuid();
var gt = new GlideRecord('sysapproval_group');
gt.initialize();
gt.parent = sysid; // Link the approval group to the task
gt.assignment_group = ""; //  assignment group
gt.approval = 'requested'; // Set initial approval state to 'requested'
gt.wait_for = 'any'; // Wait for any one approver to approve
gt.insert(); // Insert the approval group record
 
 
Now it is working like even though we got approval from any of the members in the group still it is waiting for others approval and approval still showing Requested.


please help me on this.
3 REPLIES 3

Arafath
Tera Guru

I would recommend you to use flow designer. You can opt no code solution and achieve this easily

shivatmika_19
Tera Guru

Hi @kesavanavya ,

You can use a flow designer for the requirement you have provided.

1. Create a catalog task (Note: make sure you uncheck the wait checkbox)

Screenshot 2024-12-07 at 12.21.39 PM.png

2. Ask for approval.

Screenshot 2024-12-07 at 12.23.00 PM.png

3. If Approved update the catalog task state to closed complete.

Screenshot 2024-12-07 at 12.24.54 PM.png

 

Screenshot 2024-12-07 at 12.25.38 PM.png

 

Complete Flow:

Screenshot 2024-12-07 at 12.26.37 PM.png

 

 

Yes that's how you would do it if you wanted the approval request generated (essentially) simultaneously with the task. But what if you wanted to wait on some action taken on the task? I've seen suggestions on this, one of which is waiting until the task is marked 'Closed Complete'. I know from test cases that attempting that makes the "Ask for Approval" action not wait and not get attached to the task because it's already closed. Another option I explored was using the "Approval" field on the catalog task, to move it from "Not Yet Requested" to "Requested" as a way to trigger the approval action. That works nicely except, if you keep things out-of-the-box, most task fulfillers would not have rights to update the "Approval" field and there is no UI Action to move it to "Requested". Of course, a custom UI Action could be added for this purpose, but was wondering if you or anyone else had a solution that did not require customization like that.