Need to Map "Opened by " field in RITM to "Requested by" field in SC Task - Fix script

Sairam3697
Tera Contributor

The "Opened by" field in the RITM and the "Requested by" field ( Custom field )in SC Task should be same. What is the solution ?

4 REPLIES 4

Anurag Tripathi
Mega Patron
Mega Patron

What are you talking about? Updating record that are already in? If so then all records? Even the closed ones?

OR

You want to ensure that records that get created have same?

-Anurag

Hi @Anurag Tripathi , I need it for the closed ones as well. Any suggestions ?

Sumanth16
Kilo Patron

HI @Sairam3697 ,

 

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

OR

You can set the opened by 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: openedby 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.openedby= current.openedby;

ritm.update();


})(current, previous);

 

 If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

 

Thanks & Regards,
Sumanth Meda

SN_Learn
Kilo Patron
Kilo Patron

Hi @Sairam3697 ,

 

You can make the 'Requested by' to be auto populated who ever is raising the form and make the field as read only so that they cannot change it. The opened by field will also have the same userID as of 'Requested by' in this scenario.

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.