Restrict RITM and SCTASK Visibility based on RITM assignment group

Shruthi8
Tera Contributor

Hi, 

I have a requirement to restrict the visibility if RITM and SCTASK based on the RITM assignment group for a particular catalog item, The RITM and SCTASK should be visible only to the RITM assignment group and approver group (RITM assignment group is auto populated from flow). I have tried before query BR but it's not working.

A Soultion would be helpful.

 

Before Query BR Script:

 

 if (!(gs.getUser().isMemberOf('current.assignment_group') || gs.getUser().isMemberOf("sys_id of the approver group))) {
        current.addEncodedQuery('cat_item!=sys_id of the catalog item');
    
Thanks in advance.
Shruthi
2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

In a before Query Business Rule, current.field_name is not valid as there is no current record - it's building the list.  You can accomplish your requirements with something more like this:

(function executeRule(current, previous /*null when async*/) {
	var ritmArr = [];
	var ritm = new GlideRecord('sc_req_item');
	ritm.query();
	while(ritm.next()) {
		if (!(gs.getUser().isMemberOf(ritm.assignment_group) || gs.getUser().isMemberOf("sys_id of the approver group"))) {
			if (ritm.cat_item != 'sys_id of the catalog item') {
				ritmArr.push(ritm.sys_id.toString());
			}
		} else {
			ritmArr.push(ritm.sys_id.toString());
		}
	}
	current.addQuery('sys_id', 'IN', ritmArr.join(','));
})(current, previous);

Shambhu K B
Giga Guru

Hi @Shruthi8 

Instead of query business rule, use ACL with conditions in the script section.

 

Please mark this correct/helpful if this answers your question.

Regards,

Shambhu