- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 04:20 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 04:44 AM
Thanks. In your existing script replace
target.cat_item.name
with
current.request_item.cat_item.name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 04:27 AM
Hi
You can refer to this thread which you can use:
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 04:33 AM
Hi Samuel,
Where are you using above scripts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 04:37 AM
Hi. it´s an ACL i am using this scripts just before adding the condition, i show all the script to give some context.
var target = new GlideRecord('sc_req_item');
target.addQuery('active', true);
target.query();
while (target.next()) {
gs.log("Item Name-"+target.cat_item.name);
}
var rec = new GlideRecord('sc_req_item');
rec.addQuery(current.cat_item);
rec.query();
gs.log(current.cat_item );
var answer = false; //Restrict access by default
if(gs.hasRole('itil') && target.cat_item.name == 'Technical request'){
gs.log("here");
answer = true;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2022 04:44 AM
Thanks. In your existing script replace
target.cat_item.name
with
current.request_item.cat_item.name