Priority field map from SC task to RITM and REQ table

Tejaswini9
Tera Expert

Hello Guys,

I need to map the priority field on "SC Task" table to the priority field on RITM and REQ table, because the agents will change priority on SC task table( we have 4 choices, critical, high, medium, low) and the same values should be set in the RITM and REQ, for this i thought of creating the new field in REQ and use the same field in RITM and SC task by adding the same field in form layout but the question is how to map the priority change in all the 3 tables based on the priority change in SC TASK,

Can anyone guide me is it correct procedure if not any ideas... and if possible sample script for better understanding, i dont have much idea on scripting.

 

Thank you!!! 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

There is priority field on task which can be used on RITM and REQ form

For mapping the data you need to use after update BR on sc_task table

OR

You can set the priority field on REQ and then for showing on RITM form dot walk to REQ and show that priority field

BR after update on sc_task

Condition: priority changes && current.request_item.cat_item.name == 'Your Catalog Item Name'

Script:

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

    // Add your code here

// update RITM

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.request_item);

ritm.priority = current.priority;

ritm.update();

// update REQ

var req = new GlideRecord('sc_request');

req.get(current.request_item.request);

req.priority = current.priority;

req.update();

})(current, previous);

Regards
Ankur

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

There is priority field on task which can be used on RITM and REQ form

For mapping the data you need to use after update BR on sc_task table

OR

You can set the priority field on REQ and then for showing on RITM form dot walk to REQ and show that priority field

BR after update on sc_task

Condition: priority changes && current.request_item.cat_item.name == 'Your Catalog Item Name'

Script:

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

    // Add your code here

// update RITM

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.request_item);

ritm.priority = current.priority;

ritm.update();

// update REQ

var req = new GlideRecord('sc_request');

req.get(current.request_item.request);

req.priority = current.priority;

req.update();

})(current, previous);

Regards
Ankur

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