- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Experts,
I have a MVRS, which lets requestor select user values from user table. This item creates a tasks which passes through diff teams, and teams can edit the variables in from on the users to update the information/ input the information, and then close the task.
| UserID | New Manager | New Laptop | New XYZ | New ABC | ..... |
| Selected at form submission | selected at sctask for group HR | selected at sctask for group IT | selected at sctask for group XYZ | selected at sctask for group ABC | ..... |
Please let me know the configurations i can do to achieve this result.
Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @saint
it goes same, you can use same logic and where you are making the whole variable set mandatory, then instead make the variable mandatory(e.g.
g_form.setReadOnly('variable_internal_name', true)
)
This involves nesting of if else so use the logic accordingly
please mark the solution as helpful, and if it solutions your problem then please accept as solution
Thank you
Gaurav Vaze
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
var UserGroupCheck = Class.create(); UserGroupCheck.prototype = Object.extendsObject(AbstractAjaxProcessor, { checkMembership: function() { var groupName = this.getParameter('sysparm_group_name'); var userId = gs.getUserID(); if (gs.getUser().isMemberOf(groupName)) { return "true"; } return "false"; }, type: 'UserGroupCheck' });
2] We need to create client script to call SI we created
Open the variable set
in the catalog client script tab, clieck on new
select Type OnLoad
Applies to All
This script runs when the form loads, calls the Script Include above, and then locks or unlocks the Multi-Row Variable Set (MRVS) based on the result.
Type: onLoad
UI Type: All
function onLoad() { var ga = new GlideAjax('UserGroupCheck'); // Name of the Script Include ga.addParam('sysparm_name', 'checkMembership'); // Name of the function ga.addParam('sysparm_group_name', 'Security Team'); // Replace with your group name ga.getXMLAnswer(handleResponse); // Asynchronous callback function handleResponse(response) { // If response is not "true", make the MRVS read-only if (response !== "true") { // Replace 'my_mrvs_internal_name' with your actual MRVS internal name g_form.setReadOnly('my_mrvs_internal_name', true); } } }
NOte: This is just example. kindly update as per your need
Please mark he solution as helpful if it helped you
And accept as solution
Thank you!
Gaurav Vaze
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you for your response @Gaurav Vaze ,
I can make the entire MVRS editable, but i want to achieve a way where one group can edit one varibale from the MVRS and for other teams it becomes read-only, for security. Thanks again for your detailed response and script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @saint
it goes same, you can use same logic and where you are making the whole variable set mandatory, then instead make the variable mandatory(e.g.
g_form.setReadOnly('variable_internal_name', true)
)
This involves nesting of if else so use the logic accordingly
please mark the solution as helpful, and if it solutions your problem then please accept as solution
Thank you
Gaurav Vaze
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can use onLoad catalog client script which applies on MRVS
Then check group membership for logged in user and accordingly make your variable readonly/editable.
💡 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
