Change SCTASK state in Work in Progress when assgned to field is true

NDIAYE
Tera Contributor

Hello Community,

 

I would like to set a BR on RITM, When the assigned to field is true, then the SCTASK state change to WIP.

Thanks for your input.

1 ACCEPTED SOLUTION

Kai Tingey
Tera Guru

@NDIAYE you can achieve this with a business rule on the sc_req_item table

 

set it to run on update when assigned_to changes (you can change this to whatever fits your requirements best)

KaiTingey_0-1698292382700.png

 

and have it run this script:

 

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

	if (current.assigned_to != ''){

		//query sc_task table
		var sctask = new GlideRecord('sc_task');
		sctask.addQuery('request_item',current.sys_id);
	
		//update state
		sctask.setValue('state',2);
		sctask.updateMultiple();

		//notify fulfiller
		gs.addInfoMessage('Updated state of child tasks');
	}
})(current, previous);

 

if the assigned to has changed, and the new value is not empty, it will query sc_task table for any records associated with that request item, update the state and add an info message.

View solution in original post

6 REPLIES 6

Murthy Ch
Giga Sage

Hi @NDIAYE 

Assigned to is what type of field? Usually it should be the reference type.

Also your question is not clear because let's say if you have three SCTASK associated with the RITM. Do you want to change all the three SCTASK state to WIP? 

 

Thanks,
Murthy

NDIAYE
Tera Contributor

Hello Murthy,

Thanks a lot for feedback , Yes I confirm it is a reference field. The aim being to change the state of all task associated to the RITM , In general all our items have only one task

 

Tai Vu
Kilo Patron
Kilo Patron

Hi @NDIAYE 

There's OOTB Business Rule on the Incident [incident] table. You can mimic that one.

Name: Incident State Active on Assignment

URL: https://<instance_name>/sys_script.do?sys_id=6fab2e470a0007045931f2a692878933

 

Sample below.

TaiVu_0-1698292358366.png

TaiVu_1-1698292385423.png

 

 

Let me know if it works for you.

 

Cheers,

Tai Vu

NDIAYE
Tera Contributor

hello @Tai Vu  I will have a look on it