- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 06:32 AM
Can someone please let me know how can we show Requests, RITM and SCTASKs associated to a particular cataalog item to a particular group.
We have written the below code in Business rule(run before query) but it is only hiding the list of RITM numbers and Requets(REQ) and SCTASKS are still visible.
(function executeRule(current, previous /*null when async*/) {
if (!gs.hasRole("u_Security_catalog_items") && gs.isInteractive()) {
current.addQuery("cat_item","!=","cba2e4d21b9c419445bd42e2cd4bcb31");
})(current, previous);
'cba2e4d21b9c419445bd42e2cd4bcb31' is sys id of the catalog item
Please let me know if anyone is having the solution for it
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 08:08 AM
Hope you have included the addEncoded query as well in your code?
current.addEncodedQuery("request_item.cat_item!=cba2e4d21b9c419445bd42e2cd4bcb31");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 09:00 AM
Hi
Please use the below code
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.hasRole("u_Security_catalog_items") && gs.isInteractive()) {
var reqsysid = [];
var ritm = new GlideRecord("sc_req_item");
ritm.addEncodedQuery("cat_item!=cba2e4d21b9c419445bd42e2cd4bcb31^ORcat_item=NULL");
ritm.query();
while (ritm.next()) {
reqsysid.push(ritm.request.sys_id.toString());
}
current.addEncodedQuery("sys_idIN" + reqsysid.toString());
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 01:16 PM
Hi
The above code hangs the instance and is not working.
Can you please suggest me some other code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2022 05:45 PM
Hi Is there any field in your request table which stores the catalog item name of request item??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2022 02:31 AM
Hi one field called Requested Item is present in the request table.
and the table is sc_request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2022 03:25 AM
Hi I got the answer I used
current.addEncodedQuery("u_requested_item.cat_item!=cba2e4d21b9c419445bd42e2cd4bcb31");
where u_requested_item is the field name present in sc_request table.
Thankyou for the help!