how to use single record producer for 2 different user groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday - last edited Monday
I have requirement to create a single record producer which should display the set of variables based on logged in user group. For users who are part of Group A, then this record producer should display few variables and if users not part of group A then other variables should display.
What is the best approach of doing this requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
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
Hi @Yakshitha ,
Create a client-callable Script Include that:
Checks if the logged-in user is in Group A.
Returns the choices for Variable Y based on Variable X’s value and the user group.
then
Create a Catalog Client Script (onChange) on Variable X that:
Calls the Script Include via GlideAjax.
Clears and populates Variable Y with the returned choices dynamically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @Yakshitha
For Record Producers, you should use Catalog Client Scripts since UI Policies don't work the same way as they do for regular forms.
1. Catalog Client Script of onload type
function onLoad() {
// Check if user is member of Group A
var ga = new GlideAjax('GroupCheckUtil');
ga.addParam('sysparm_name', 'isUserInGroup');
ga.addParam('sysparm_group_name', 'Group A'); // or use sys_id
ga.getXMLAnswer(function(answer) {
if (answer == 'true') {
// User is in Group A - show Group A variables
g_form.setDisplay('group_a_variable_1', true);
g_form.setDisplay('group_a_variable_2', true);
g_form.setDisplay('other_variable_1', false);
g_form.setDisplay('other_variable_2', false);
} else {
// User is NOT in Group A - show other variables
g_form.setDisplay('group_a_variable_1', false);
g_form.setDisplay('group_a_variable_2', false);
g_form.setDisplay('other_variable_1', true);
g_form.setDisplay('other_variable_2', true);
}
});
}
2.Create Script Include (Client Callable)
var GroupCheckUtil = Class.create();
GroupCheckUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isUserInGroup: function() {
var groupName = this.getParameter('sysparm_group_name');
return gs.getUser().isMemberOf(groupName).toString();
},
type: 'GroupCheckUtil'
});Hope this helps, if helped then kindly mark helpful & accept as solution 🙂
Warm Regards
Sumit
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
But I have a variable X and based on the values of X the choices of Y variable should display. But the choices of Y is different for group A and non group A members. This is the requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi @Yakshitha
you can use script include and then use onChange catalog client script
**Script Include **
** onChange catalog client script **
💡💡If you find this any helpful ,give me thumbs 👍up and accept the solution✔️.
Regards,
Abhishek
Technical Consultant
