ACL script help to check member is belongs to assignment group provide read access?

Vijay27
Tera Guru

answer = getAttachmentReadAnswer();

function getAttachmentReadAnswer() {

var user=gs.getUserID();
gs.info("user name is:"+user);                //in logs it is giving correct user
var grp=current.assignment_group;       
gs.info("currentgrp name is"+grp);          //in logs it is giving null
if(current.assigned_to == user)
return true;
else if(user.isMemberOf(current.assignment_group) {
return true;
}
else return false;

 

I want to provide access to seee the attachment attached on the case if the user opens a case and he belongs to assignment group of the case.

The above script  is not working in ACL script .please help me on the ACL scriptong ony on how to check this one

Regards,

vijay

1 ACCEPTED SOLUTION

try below

answer = getAttachmentReadAnswer();

function getAttachmentReadAnswer() {
	var gr = new GlideRecord("task");
	gr.get("sys_id", current.table_sys_id);
		
	var user=gs.getUserID();
	gs.info("user name is:"+user);                //in logs it is giving correct user
	var grp=gr.assignment_group;
	gs.info("currentgrp name is"+grp);          //in logs it is giving null
	if(current.assigned_to == user){
		return true;
	}else if(gs.getUser().isMemberOf(gr.assignment_group)) {
		return true;
	}else{
		return false;
	}
}

View solution in original post

8 REPLIES 8

Mike Patel
Tera Sage

which table you have this acl on and try doing below

answer = getAttachmentReadAnswer();

function getAttachmentReadAnswer() {
	var user=gs.getUserID();
	gs.info("user name is:"+user);                //in logs it is giving correct user
	var grp=current.assignment_group;
	gs.info("currentgrp name is"+grp);          //in logs it is giving null
	if(current.assigned_to == user){
		return true;
	}else if(gs.getUser().isMemberOf(current.assignment_group)) {
		return true;
	}else{
		return false;
	}
}

Tablename:sys_attachment 

running on :sn_hr_core_case table

You don't have any check for 'sn_hr_core_case table' table in your code, so this will run for attachments on all record types.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022