Make catalog variables editable for a particular group memebers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2025 04:32 AM
Hi All,
I have a requirement to make the RITM variables editable for a particular group members once the RITM is in 1st stage of approval.
for example: 1st stage of approval goes to 'Business Solution' group, so the members of that group should have access to edit the variables on the RITM form.
I have written a client callable script include to check the group membership. If it return true, variables should be editable over RITM form but the variables are not editable.
Script Include:
var canEditRITMVariables = Class.create();
canEditRITMVariables.prototype = Object.extendsObject(AbstractAjaxProcessor, {
// Client-callable function
canEditRITMVariables: function() {
var userSysId = this.getParameter('sysparm_user');
var groupSysId = this.getParameter('sysparm_group');
if (this.isUserInGroup(userSysId, groupSysId)) {
return 'true'; // user can edit
}
return 'false'; // restrict editing
},
// Helper: check group membership
isUserInGroup: function(userSysId, groupSysId) {
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('user', userSysId);
grMember.addQuery('group', groupSysId);
grMember.query();
return grMember.hasNext();
},
type: 'canEditRITMVariables'
});
Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
if (g_form.getValue("cat_item") == "d025b6ff870ce950fa770d47cebb3566") {
var ga = new GlideAjax('canEditRITMVariables');
ga.addParam('sysparm_name', 'canEditRITMVariables');
ga.addParam('sysparm_user', g_user.userID);
ga.addParam('sysparm_group', '56f1f8240f9d82004fb50f8ce1050e2f'); // replace with group sys_id 56f1f8240f9d82004fb50f8ce1050e2f
ga.getXMLAnswer(function(response) {
var canEdit = response === 'true';
if (!canEdit) {
g_form.setVariablesReadOnly(false);
}
});
}
}
Can someone plz help on this why this code is not working. I have ran the code in the scripts-background and the result is coming as true still the variables are non-editable for the users.
Thansk,