- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 08:16 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 07:56 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 10:51 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 11:44 PM - edited 11-12-2022 08:58 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2022 07:56 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 05:53 AM
Glad to know that my script worked.
Please mark response helpful as well.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader