trigger an approval based on a field on the Technical Service

Diane22
Tera Guru

Technical Service has a field for CSI Managers

There is an approval group containing all CSI Managers 

I need to trigger the approval, to not go to all CSI managers in that group, but to the specific one defined on the Technical Service

ie:  not trigger to all CSI managers but only to the impacted one (and delegates)

 

Would using the sysID work?  ideas?

 

1 REPLY 1

Deepak Shaerma
Kilo Sage

Hi @Diane22 

 In your workflow or flow designer, where you would typically set up an approval action, opt for a script-based approach.

var techServiceGR = new GlideRecord('technical_service_table_name'); // Replace ‘technical_service_table_name’ with the actual table name
techServiceGR.get('sys_id', current.u_technical_service); // Assuming ‘current.u_technical_service’ references the field holding the Technical Service record’s Sys ID

if (techServiceGR.isValidRecord()) {
    var csiManagerSysID = techServiceGR.getValue('u_csi_manager'); // Assuming ‘u_csi_manager’ is the field holding the CSI Manager’s Sys ID

    // Now, create the approval record directly targeting the CSI Manager
    var approvalGR = new GlideRecord('sysapproval_approver');
    approvalGR.initialize();
    approvalGR.approver = csiManagerSysID; // Set the approver to the CSI Manager
    approvalGR.state = 'requested';
    approvalGR.document_id = current.sys_id; // Relate this approval to the current record being processed
    approvalGR.insert();
}

Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma