Field should be visible only for one set of people who group name contains SM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi Team,
We have a requirement u_kb_article field on change request should be visible only for people who belong to group names contains "SM", we have multiple groups that has "SM" in like Test -SM-test. how can i achieve this?
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @Atchutaram
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @Atchutaram,
from design perspective a condition that "group starts of [XY]" doesn't seem to be optimal.
ACL
- Consider adding a new group type (that can be called "SM") and make the display condition in ACL based on the group type...
Role
- Or onLoad (catalog) client script with g_user.hasRoleExactly('');
Group name starting with "SM"
- it would require a onLoad catalog client script to display in Portal and one client script to display in backend, both would call a GlideAjax call to check if the logged in user has been a member of "SM" group.
g_scratchpad
- display BR and onLoad client script
- backend only
- not applicable in portal
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Multiple ways to achieve
1) you can use field level READ ACL on that field, use advanced script in ACL, ensure you give correct role in ACL
var userId = gs.getUserID();
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group.name', 'LIKE', 'SM');
gr.setLimit(1);
gr.query();
answer = gr.hasNext();
OR
2) Display business rule + onLoad client script
Display BR on change_request table
(function executeRule(current, previous /*null when async*/ ) {
var userId = gs.getUserID();
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group.name', 'LIKE', 'SM');
gr.setLimit(1);
gr.query();
g_scratchpad.show_kb_article = gr.hasNext();
})(current, previous);
onLoad client script
function onLoad() {
// Check the value from g_scratchpad
var canSeeKbArticle = g_scratchpad.show_kb_article;
if (canSeeKbArticle) {
g_form.setVisible('u_kb_article', true);
} else {
g_form.setVisible('u_kb_article', 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
Monday
Hope you are doing good.
Did my reply answer your question?
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