Auto Assignments of SCTASKS

NiKhil70
Kilo Guru

Hi 

I have a requirement for Auto Assignment of SCTASK .

When we submit the Request form , REQ & RITM will be created .

In RITM , "Assigned to" is not Auto Assigned , only Assignment Group is Auto Assignment .

If i open the RITM and Assign to user "TEST" , all the SCTASKS should Auto Assign to user "TEST" .

Require inputs on the above Requirement .

Thanks

NR.

1 ACCEPTED SOLUTION

prasannaposetty
Tera Expert

Hi NR,

 

You can write an After Update business rule on Assigned To field.

When: after

Update: True

Table: Requested Item (sc_req_item)

Filter Conditions: Assigned To changes

Script:

 

(function executeRule(current, previous /*null when async*/) {

// Auto assign SC Tasks based on RITM Assigned To
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item' , current.sys_id);
gr.query();
while(gr.next()){
gr.assigned_to = current.assigned_to;
gr.update();
}

})(current, previous);

View solution in original post

3 REPLIES 3

Sandeep Kumar6
Giga Guru

HI NR,

Thanks to be a member of Community.

I would suggest you create Assignment Rule 

Navigate to System Policy -> Assignment --> Create new Assignment rule there 

You can assign to User or group or you can use script for assignment.

 

For Auto User assignment you have to write on load client script or  trigger a workflow whenever a Assignment Group is not empty or changes its value .

Then you fetch one user from that group and assign  to Assign TO field.

You can make use of below two line

if (current.assignment_group)
localUsers = (new SMFilters())._retrieveGroupMembersIds(current.assignment_group.toString());

 

 

Now for your second requirement you can create on change client script on field "Assign To" field 

Whenever you change the value of " Assign To " field get all the related task and assign all the task to same user.

 

Please hit mark correct or Helpful if this helped you in you answer.

Regards

Sandeep

prasannaposetty
Tera Expert

Hi NR,

 

You can write an After Update business rule on Assigned To field.

When: after

Update: True

Table: Requested Item (sc_req_item)

Filter Conditions: Assigned To changes

Script:

 

(function executeRule(current, previous /*null when async*/) {

// Auto assign SC Tasks based on RITM Assigned To
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item' , current.sys_id);
gr.query();
while(gr.next()){
gr.assigned_to = current.assigned_to;
gr.update();
}

})(current, previous);

Hi Prasanna ,

 

It worked with your script , working as expected .

Thanks

NR .