How to set values of RITM State value based on Catalog task state value in a workflow

Ansuha Chipuri
Kilo Guru

Hi

My Workflow just creates as catalog task whenever a RITM is created. Now

How to set values of RITM State value based on Catalog task state value in a workflow

Like if  Catalog task state is Closed Complete, RITM state  should be closed Complete

       if  Catalog task  state is Closed Incomplete, RITM state should be Closed Incomplete

With regards 

1 ACCEPTED SOLUTION

Prasant Kumar 1
Kilo Sage

Hi,

Please follow the below steps:-

Step 1:- In Work flow after catalog task activity insert an run script activity and Enter the following code below.

var catTask = new GlideRecord('sc_task');
catTask.get('request_item',current.sys_id);
if(catTask.state == 3){    //'3' for state closed complete in catalog task table(sc_task)
current.state = 3;            //'3' is ritm close complete state value.
current.update();
}

//Like wise you can generate other state value conditions....

 

If i was able to solve your query, please mark my answer correct and helpful.

Thanks & Regards

Prasant Kumar sahu

View solution in original post

5 REPLIES 5

Prasant Kumar 1
Kilo Sage

Hi,

Please follow the below steps:-

Step 1:- In Work flow after catalog task activity insert an run script activity and Enter the following code below.

var catTask = new GlideRecord('sc_task');
catTask.get('request_item',current.sys_id);
if(catTask.state == 3){    //'3' for state closed complete in catalog task table(sc_task)
current.state = 3;            //'3' is ritm close complete state value.
current.update();
}

//Like wise you can generate other state value conditions....

 

If i was able to solve your query, please mark my answer correct and helpful.

Thanks & Regards

Prasant Kumar sahu

asifnoor
Kilo Patron

Hello Anusha,

Create a after update Business rule on catalog task table 

Filter conditions: state changes to closed complete 

OR

state changes to closed incomplete

Script

var ritm = new GlideRecord('sc_req_item');
if(ritm.get(current.request_item)) {
   ritm.state=current.getValue("state");
   ritm.update();
}

Mark the comment as a correct answer and also helpful once worked.

Ankur Bawiskar
Tera Patron
Tera Patron

@Ansuha Chipuri 

you can have 2 approaches

1) either use workflow run script after the catalog task activity to update RITM state

a) get the catalog task for this RITM and update RITM

OR

2) after update BR on sc_task

BR Approach:

After update:

Condition: Ensure this BR runs only for your catalog item so give your catalog item name here

current.request_item.cat_item.name == 'Catalog Item Name' && (current.state == '3' || current.state == '4')

Script:

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

    // Add your code here

var ritmRecord = current.request_item.getRefRecord();

ritmRecord.state = current.state;

ritmRecord.update();

})(current, previous);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

There are 2 scenarios –
If there is 1 RITM & 1 Task – RITM state follows the Task state. ( Your solution works here)
If there is 1 RITM & 2 or more Tasks – ??

Any help with the above request.

Thanks, Jay