Assignment group on my sc_task table same as the sc_req_item table.

dhineshkumar
Tera Guru

Hi Experts 
I have the requirement, When I select the any group name on my sc_req_item table that same group name should be on my sc_task table assignment group dynamically . How to achieve this task.

 

dhineshkumar_0-1680979633295.jpeg   

dhineshkumar_1-1680979695800.jpeg

 

1 ACCEPTED SOLUTION

Prince Arora
Tera Sage
Tera Sage

@dhineshkumar ,

 

Please write a business rule as follows:

 

PrinceArora_0-1680981607792.png

 

Script:

 

if(current.variables.group != previous.variables.group){ /backend name of group please check
var gr = new GlideRecord("sc_task");
gr.addEncodedQuery("request_item=" + current.sys_id);
gr.query();
while(gr.next()){
gr.assignment_group = current.variables.group; //please check backend name of group
gr.update();
}
}

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

2 REPLIES 2

Bert_c1
Kilo Patron

Hi,

 

You could use a business rule defined on the sc_req_item table, that updates the assignment_group on those sc_task records And use the following script:

 

 

 

// update related task with he assignment group
var scTask = new GlideRecord('sc_task');
scTask.addQuery('request_item', current.sys_id.toString());
scTask.query();
while (scTask.next()) {
	//see if group on related task needs changing
	if (scTask.assignment_group != current.assignment_group) {
		gs.addInfoMessage("Setting assignment group: " + current.assignment_group.getDisplayValue() + " for " + scTask.number);
		scTask.assignment_group = current.assignment_group;
		scTask.update();
	}
}

 

 

in the body of the script. I would configure the BR to run on Update and Insert, and to run "After". And a condition of "Assignment group", "changes"

Prince Arora
Tera Sage
Tera Sage

@dhineshkumar ,

 

Please write a business rule as follows:

 

PrinceArora_0-1680981607792.png

 

Script:

 

if(current.variables.group != previous.variables.group){ /backend name of group please check
var gr = new GlideRecord("sc_task");
gr.addEncodedQuery("request_item=" + current.sys_id);
gr.query();
while(gr.next()){
gr.assignment_group = current.variables.group; //please check backend name of group
gr.update();
}
}

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.