RITM should reflect Closed Complete, Incomplete or Skipped depending on Task

mallikabhupathi
Tera Expert

Hi,

I have a requirement where the state of the RITM should be the same as the SCTask. When the SCTask is set to Closed incomplete, the RITM should show state as Closed Incomplete, if the SCTask is set to Closed Skipped, the RITM should show state as Closed Skipped, SCTask is set to Closed Complete, the RITM should show state as Closed Complete.

I have tried the workflow route and business rules route but nothing seems to be working.

Any help would be appreciated.

Thanks,

Mallika

1 ACCEPTED SOLUTION

Line number 10 is incorrect in your script. Please use the exact version of script as shared above. You don't need to hard code any sys id there.

Please use the exact script with no change required here.

Sharing it again for reference below:

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

	// Add your code here
	if(current.state.changes()){
		updateRITMState(current.request_item,current.state);
	}
	
	function updateRITMState(RitmID,state){
		var gr = new GlideRecord('sc_req_item');
		gr.addQuery('sys_id',RitmID);
		gr.query();
		if(gr.next()){
			gr.state = state;
			gr.update();
		}
	}
	

})(current, previous);

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

6 REPLIES 6

Saurav11
Kilo Patron
Kilo Patron

Hello

After the catalog task workflow just write a if logic check the state of task and based in that have rwo set values attribute it will then move it to the one which we require

Thanks

shloke04
Kilo Patron

Hi @mallikabhupathiraju 

Please follow the steps below to achieve your requirement:

BR:

Table : Catalog Task

After Update

Condition of BR: State Changes;

Script:

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

	// Add your code here
	if(current.state.changes()){
		updateRITMState(current.request_item,current.state);
	}
	
	function updateRITMState(RitmID,state){
		var gr = new GlideRecord('sc_req_item');
		gr.addQuery('sys_id',RitmID);
		gr.query();
		if(gr.next()){
			gr.state = state;
			gr.update();
		}
	}
	

})(current, previous);

find_real_file.png

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi @shloke04 ,

 

find_real_file.png

 

find_real_file.png'

It is still closing the task as Closed Complete.

Line number 10 is incorrect in your script. Please use the exact version of script as shared above. You don't need to hard code any sys id there.

Please use the exact script with no change required here.

Sharing it again for reference below:

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

	// Add your code here
	if(current.state.changes()){
		updateRITMState(current.request_item,current.state);
	}
	
	function updateRITMState(RitmID,state){
		var gr = new GlideRecord('sc_req_item');
		gr.addQuery('sys_id',RitmID);
		gr.query();
		if(gr.next()){
			gr.state = state;
			gr.update();
		}
	}
	

})(current, previous);

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke