Is there a Way to Make MVRS variables editable on SCTASK for a particular group?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours 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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago - last edited an hour 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
35m 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.
