I want to set the Sc task state value to RITM state when state changes of Sc task
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎11-11-2023 02:15 AM
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎11-11-2023 06:08 AM
Hello @posasaihimahars
Write a BR :-
(function executeRule(current, previous /*null when async*/) {
	var status = current.request_item.variables.comp_reviewStatus;
	var tr=new GlideRecord('sc_req_item');
tr.addQuery('sys_id',current.request_item);
tr.query();
tr.next();
    if (status == "under_review") {
		tr.state = 2;  // Work in Progress
tr.update();
	}
	else if (status == "awaiting_client") {
		tr.state = 5;  // Awaiting Client
tr.update();
	}
	else if (status == "completed") {
		tr.state = 2;  // Work in Progress
tr.update();
	}
})(current, previous);
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎11-11-2023 06:14 AM
Navigate to "Business Rules" in the ServiceNow application.
Create a new Business Rule.
Set the "Filter Conditions" to target the specific conditions when you want this rule to run (e.g., when the state changes).
(function executeRule(current, previous /*null when async*/) {
if (current.state != previous.state) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.ritm)) {
ritm.state = current.state;
ritm.update();
}
}
})(current, previous);
