How to set other approver state to 'No longer required' if one Approver approved the CTASK

saran raj
Tera Contributor

Hi,

A CTASK has a group approval where all the members in the group should approve or group approval should be provided, but the user is requesting to make approval - No longer required if any user in the group approves it. A run script is configured to create a standard change. How can I achieve this by modifying in the run script. Below is the script for reference. Please guide me to set other approver state to 'No longer required' if one Approver approved.

 

var template = new GlideRecord('std_change_producer_version');
//Firewall template
template.get('std_change_producer', '2df0e45147a4ddd4ff96ebbd436d43ae');
template.orderByDesc('sys_updated_on');
template.setLimit(1);
template.query();
 
 
while(template.next())
{
 
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'standard';
chg.category = 'Enhancement';
chg.std_change_producer_version = template.sys_id;
chg.applyTemplate(template.std_change_producer.name);
chg.start_date = new GlideDateTime(current.variables.start_deploy_date);
chg.end_date = new GlideDateTime(current.variables.end_deploy_date);
chg.parent = current.sys_id;
chg.assignment_group.setDisplayValue('Network.Operations.GLBL.IM.SUP');
chg.opened_by = current.opened_by;
chg.requested_by = current.opened_by;
chg.comments = current.comments.getJournalEntry(-1);
chg.u_service_catalog_source = '2df0e45147a4ddd4ff96ebbd436d43ae'; //Firewall
chg.u_request_type = 'Firewall Change Request';
chg.short_description = current.short_description;
chg.description = current.description;
 
var change = chg.insert();
 
GlideSysAttachment.copy('sc_request', current.getUniqueValue(), 'change_request', chg.getUniqueValue());
var chgtask = new GlideRecord('change_task');
chgtask.initialize();
chgtask.u_type = 'Validation';
chgtask.assignment_group = '75dbecd0606e4100a210b5d776ef5aa0';
chgtask.parent = change;
chgtask.short_description = "[Validation Task]" + chgtask.parent.number.getDisplayValue() + ':' + current.short_description;
var change_task = chgtask.insert();
var approver = new GlideRecord('sysapproval_group');
approver.parent = change_task;
approver.assignment_group = '75dbecd0606e4100a210b5d776ef5aa0';
approver.approval = 'requested';
approver.insert();
}
 
8 REPLIES 8

SinghBalwant
Kilo Guru

Initially, it is recommended that you modify this aspect within your workflow. Take a look at the Group Approval activity in the workflow and verify that the specified options are chosen. Typically, when an individual grants approval, the status of other participants automatically transitions to 'No longer required.'

 

Hi @SinghBalwant 

This approval is modified in a run script and not through any activity. Moreover the workflow points out to sc_request, so if I add any group approval activity, the approvers are reflected in the request instead of ctask.

John Dewhurst
Kilo Guru

I'd generate your approval using flow or subflow instead of generating it by script, this will cause the approval actions to be handled correctly

Hi @John Dewhurst 

Could you please explain in detail how to achieve approval using flow or sub flow instead of generating it by script?