The CreatorCon Call for Content is officially open! Get started here.

Copy the cat_item from the sc_req_item to the sc_task

Samuel Moya cam
Kilo Sage

Hi i am trying to get the cat_item from the sc_req_item and trying to copy it to the sc_task to add a condition to an acl.
This is what i got
1- This script gives me all the cat_item names but not the current cat_item from the sc_req_item

var target = new GlideRecord('sc_req_item');


target.addQuery('active', true);


target.query();  

while (target.next()) {  


                      gs.log("Item Name-"+target.cat_item.name);


}

2- This gives me an undefined value

var rec = new GlideRecord('sc_req_item');


rec.addQuery(current.cat_item);


rec.query();


gs.log(current.cat_item );

 

 

Thank you

1 ACCEPTED SOLUTION

Thanks. In your existing script replace

target.cat_item.name 

with

current.request_item.cat_item.name

View solution in original post

9 REPLIES 9

dmathur09
Kilo Sage

Hi Samuel,

You can directly dot walk in your ACL which is created on the sc_task table and fetch the catalog item record.

Regards,

Deepankar Mathur

 

Hi, you mean i can directly get the cat_item values from the sc_req_item?

yes, to get it from RITM you can use current.cat_item, for sc_task use current.request_item.cat_item

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

to get catalog item name in ACL of sc_task use this

var itemName = current.request_item.name;

Regards
Ankur

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

Scott Halverson
ServiceNow Employee
ServiceNow Employee

This looks to be out of the box in Utah.  sc_task.cat_item with a default javascript to populate the reference.