How to copy the Assignment Group Name from RITM to SCTask

Bijay Kumar Sha
Giga Guru

Hi,

I've a 3rd Party Integration. They raise a request from their tool and one REQ is being generated in ServiceNow through a catalog Item and corresponding RITM is being assigned to a particular Assignment group defined in the process. 

However, I'm seeing an SCTask under that RITM is also being generated with blank Assignment group.

How I can copy the same assignment group from the RITM to underneath SCTask.

I'm thinking to write a BR in SCTask table where it'll copy the assignment group from RITM to that particular record in SCTask.

Can anyone please help on this?

1 ACCEPTED SOLUTION

SN_Learn
Kilo Patron
Kilo Patron

Hi @Bijay Kumar Sha ,

 

In the catalog item, there will be either flow/workflow attached. Please check that there will be one activity for creation of sctask. You can define the assignment group there or you can copy the same assignment group as of RITM as below in the catalog task in workflow:

SN_Learn_0-1721813708096.png

 

 

You can achieve it via business rule on sc_task table:

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

    var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('sys_id', current.request_item);
    ritm.query();
    if (ritm.next()) {
        ritm.assignment_group = current.assignment_group; 
	ritm.update();
    }

})(current, previous);

 

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

5 REPLIES 5

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Bijay Kumar Sha You can write a Business Rule (BR) on the SCTask table that triggers whenever a new record is inserted (insert/update), and it will copy the Assignment Group from the corresponding RITM.

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

    var ritmGr = new GlideRecord('sc_req_item');
    if (ritmGr.get(current.request_item)) {
        current.assignment_group.setDisplayValue(ritmGr.assignment_group.getDisplayValue());
    }

})(current, previous);

 

Hi @Sid_Takali ,

Can you please let me know, if it's generic or specific to the catalog item that I'm talking about? Because, there might be chances for other RITMs, underneath there may be multiple SCTasks and those are assigned to different assignment groups.

For this, I've one catalog item and assignment group is getting populated in the RITM level not in corresponding SCTask.

Hope you get my point

Anurag Tripathi
Mega Patron
Mega Patron

You can do so using a BR or where you are generating the SC_task (flow/workflow).

I would suggest you start writing something and post here if it doesn't work.

 

 Add conditions that it runs only for RITMs created for this catalog item and also only for this task.

 

copying assignment group would be like below, current is your sc_task here

current.assignment_group = current.request_item.assignment_group;

 

-Anurag

Mark Manders
Mega Patron

You will need to check on your setup. If you have a separate (work)flow or logic for just this RITM, you can apply it in there. If it's a generic one, you need to adjust it to only do it for this item. 

Without knowing your setup, there are too many possible ways to do this (BR's, workflows, flows, and even on load scripts).


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark