- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-15-2021 02:54 AM
Hi All,
Hope everyone is doing good.
I am working on a catalog form with Variables,
Name (reference to User table), Department, Work Location, Telephone, Email. When value changes in Name variable, all the other variables get populated automatically if the user in Name variable has that values exist. If not, we are allowing users to manually enter values in Department, work location, telephone, email variables.
We have a MRVS with the same variables as mentioned above.
Now, We have a checkbox variable on the same form with name "Self". When user checks it to true, all the values in the Name, Department, work location, telephone, email should be copied to variables in MRVS. If he unchecks, the values should get cleared (only the row should get deleted which is populated when the variable is checked). This should work on change of both Name and Self variables.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-21-2021 06:17 AM
Done and working fine in native
please check below output
Please mark my response as correct and close the question.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2021 02:34 AM
Hi Ankur Bawiskar,
I have the exactly the same requirements as this? Is it ok to share to me as well?
Requirements:
Requestor (reference), self (checkbox) and MRVS (with variables, Name, Email Address). Reference to sys_user table as well.
Please please help.
thanks,
Sarah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2021 03:18 AM
you can use the script similar to above.
Just enhance it as per your requirement
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2021 07:29 AM
I have create onChange client script in my checkbox "include_me_in_the_access".
My Requested for is "itsm_requested_by" and my mrvs is "users_who_need_access". But no luck. Where did I go wrong?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
var user = g_form.getDisplayValue('itsm_requested_by').value;
var selfDetails = [];
var details = '';
var obj = {};
obj["name"] = g_form.getDisplayValue('itsm_requested_by').value;
obj["ntid"] = g_form.getValue('u_network_id');
selfDetails.push(obj);
details = JSON.stringify(selfDetails);
if (newValue == 'true' & user != '') {
g_form.setValue('users_who_need_access', details);
} else if (newValue == 'false' || user == '') {
var selfDetails1 = [];
var details1 = '';
var obj2 = {};
obj2["name"] = g_form.getDisplayValue('itsm_requested_by').value;
obj2["ntid"] = g_form.getValue('u_network_id');
selfDetails1.push(obj2);
details1 = JSON.stringify(selfDetails1);
alert(details1);
var toRemove = g_form.getDisplayValue('itsm_requested_by').value;
var finalArr = [];
var parser = JSON.parse(JSON.stringify(details1));
alert (parser);
for (var i = 0; i < parser.length; i++) {
var obj1 = parser[i];
alert(obj1);
var newParser = JSON.stringify(obj1);
//alert(newParser);
if (newParser.name.toString() != toRemove.toString()) {
finalArr.push(obj1);
}
}
alert('new JSON' + JSON.stringify(finalArr));
if (parser.name.toString() == toRemove.toString()) {
finalArr.push(obj1);
}
g_form.setValue('users_who_need_access', JSON.stringify(finalArr));
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-30-2021 08:10 AM
Just also wanted to ask. Did you use script include here or just two client scripts?
1. for the variable Requested For
2. for the checkbox self
Is that correct?