Outage Approval Trigger

-ooo-
Tera Contributor

Hello Team,

 

I need to trigger the approval to Approval group , owned by and Managed By  for affected CIs and Affected Business Services if Outage is present . If it not present then Needs to Trigger Notification Approval group , owned by and Managed by on change Table while moving towards to request approval button.

 

Initially I created  workflow and write script on that for approval. it was triggering approval . but now only condition added  if outage is present .

 

Please Advise. 

3 REPLIES 3

SwarnadeepNandy
Mega Sage

Hello @-ooo-,

One possible way to trigger the approval to Approval group, owned by and Managed By for affected CIs and Affected Business Services if Outage is present is to use a condition script in your workflow activity. For example, you can use the Approval - Group activity1 to create approval records for each member of a specified group, and then add a condition script that checks if there is an outage associated with the change request. You can use the Task-Outage table2 to query the outage information for a given task. Here is a sample condition script that illustrates this idea:

 

// Get the current change request
var change = workflow.scratchpad.target;

// Query the task_outage table for records where the task is the current change request
var taskOutageGR = new GlideRecord('task_outage');
taskOutageGR.addQuery('task', change.sys_id);
taskOutageGR.query();

// If there is an outage record, return true to trigger the approval
if (taskOutageGR.hasNext()) {
  return true;
}

// Otherwise, return false and send a notification to the Approval group, owned by and Managed by
else {
  // Get the Approval group, owned by and Managed by from the change request
  var approvalGroup = change.approval_group;
  var ownedBy = change.owned_by;
  var managedBy = change.managed_by;

  // Create a list of recipients
  var recipients = [];
  recipients.push(approvalGroup);
  recipients.push(ownedBy);
  recipients.push(managedBy);

  // Send a notification to the recipients
  // You can use gs.eventQueue() or gs.email() or any other method you prefer
  // For example, you can use gs.eventQueue() with an event name and a list of parameters
  gs.eventQueue('change.no.outage', change, recipients.join(','), '');

  // Return false to skip the approval
  return false;
}

 

You can modify this script to suit your specific needs. 

 

Hope this helps.

 

Kind Regards,

Swarnadeep Nandy

Hello @SwarnadeepNandy  Getting 

ooo_0-1693484607916.png

 

Getting parsing error outside of the function 

Whats the error? If it states code not reachable, then its fine. Save it and you are good to go.