Unable to fetch value of reference field using glide record in acl

Renu9
Tera Contributor

Hi All,

I need to display few fields on the RITM only to the members of the approval group of the ritm and to others it should be visibility restricted 

Fields : work notes

So I have written a field level read ACL on ritm table for the work notes field .

I am glide recording to sysapproval group table and trying to match the ritm number with the approval group table parent(reference field to ritm)

I'm unable to get the value of parent of approval group table. Please guide.

 

Var gr= new GlideRecord('sysapproval_group);

gr.addQuery(gs.getDisplayValue('parent'), number);

gr.query();

.

.

 .

.

 

Undefined is getting displayed for the log of the parent value. tried with display box getreference , etc but nothing worked. . please guide here 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Renu9 

update as this

var gr = new GlideRecord('sysapproval_group');
gr.addQuery('parent', current.sys_id);
gr.query();
if(gr.next()){
	if(gs.getUser().isMemberOf(gr.getValue('assignment_group')))
		answer = true;
	else
		answer = false;
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Gunjan Kiratkar
Kilo Patron
Kilo Patron

If you don't want to use ACL then another approach

1) Display BR

if(gs.getUser().isMemberOf("Approval Group")){. // Replace "Approval Group" with your approval group name
g_scratchpad.isValid = 'true';
}else{
g_scratchpad.isValid = 'false';
}

2) Client Script:

function onLoad(){

g_form.setDisplay('work_notes', false); // 1st hide it

if(g_scratchpad.isValid == 'true'){

// if valid then show and make it editable

g_form.setDisplay('work_notes', true);

g_form.setReadOnly('work_notes', false);

}

}

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

I have to use ACL only as I should hide the fields for other users in list view as well.

And approval group field is not on ritm form. It is in different table (sysapproval_group) table.

It is mapped as related list to ritm form

 

@Ankur Bawiskar 

Ankur Bawiskar
Tera Patron
Tera Patron

@Renu9 

update as this

var gr = new GlideRecord('sysapproval_group');
gr.addQuery('parent', current.sys_id);
gr.query();
if(gr.next()){
	if(gs.getUser().isMemberOf(gr.getValue('assignment_group')))
		answer = true;
	else
		answer = false;
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Renu9 

Glad to know that my script worked.

Please mark response helpful as well.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader