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

How to show the Requests, RITM and SCTASKs associated of a particular catalog item to a particular group only?

AKASH BANERJEE
Mega Guru

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

1 ACCEPTED SOLUTION

Hope you have included the addEncoded query as well in your code?

current.addEncodedQuery("request_item.cat_item!=cba2e4d21b9c419445bd42e2cd4bcb31");

View solution in original post

9 REPLIES 9

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);

Hi

The above code hangs the instance and is not working.

Can you please suggest me some other code.

Hi Is there any field in your request table which stores the catalog item name of request item??

Hi one field called Requested Item is present in the request table.

and the table is sc_request

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!