Auto-assign a service catalog task

Merza Lyn
Mega Guru

I have a requirement from one of our catalog item (New User Account Request).

The workflow of this is once approved, it will generate the 1st task = Access Provisioning - Domain.

Then once the Access Provisioning - Domain is closed, another tasks are generated. Once of the is "Access Provisioning - Office 365 Email". 

The customer requested that who ever closes the Access Provisioning - Domain should be automatically assigned to the 'Access Provisioning - Office 365 Email' task.

 

How to achieve this?

1 ACCEPTED SOLUTION

Merza Lyn
Mega Guru

I have my solution here.

In the workflow Activity Properties for the Catalog Task "Access Provisioning - Office 365 Email", I checked the Advanced and add script below.

var domainTask = new GlideRecord('sc_task');
domainTask.addQuery('short_description', 'Access Provisioning - Domain');
domainTask.addQuery('parent', current.sys_id);
domainTask.addQuery('state', 3); // Check if it's closed complete
domainTask.query();
if (domainTask.next()) {
   // Assign the O365 task to the user who closed the Domain task
   task.assigned_to = domainTask.closed_by; // closed_by field

 

View solution in original post

2 REPLIES 2

GlideFather
Tera Patron

Write a business rule on the sc_task table and set it similarly:
- triggered on Update,
- condition: state changes (moves) to Closed Complete or Closed Incomplete,

Screenshot 2024-10-21 at 08.16.25.png


Then you can set the fields without a line of code:

KamilTerl_0-1729495103082.png

 


PS: this will be applied to all the SCTASKs, if you want to have it for just one particular item, it needs to be adjusted accordingly in the conditions

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Merza Lyn
Mega Guru

I have my solution here.

In the workflow Activity Properties for the Catalog Task "Access Provisioning - Office 365 Email", I checked the Advanced and add script below.

var domainTask = new GlideRecord('sc_task');
domainTask.addQuery('short_description', 'Access Provisioning - Domain');
domainTask.addQuery('parent', current.sys_id);
domainTask.addQuery('state', 3); // Check if it's closed complete
domainTask.query();
if (domainTask.next()) {
   // Assign the O365 task to the user who closed the Domain task
   task.assigned_to = domainTask.closed_by; // closed_by field