- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
How to pass a value from one variable set to another variable set in catalog form,
I have requestor in variable set 1, i want to copy that value into variable set 2 how to acheive this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
got it.
So variable within MRVS should have reference qualifier based on outside variable
yes this is possible you can access outside variable in reference qualifier of MRVS variable
see these links for help
SOLVED: Issue with MRVS multi row variable set accessing the form values
Yes, You Can Effectively Set or Update a Reference Qualifier Via Script!
OR
Another easy approach
1) create a hidden single line text variable within MRVS and hide it always
2) use onLoad catalog client script which runs on MRVS and set this hidden variable with outside variable
function onLoad() {
g_form.setValue('hiddenVariable', g_service_catalog.parent.getValue("requested_for"));
}
3) now you have outside variable value available within MRVS and you can apply ref qualifier on your variable like this
javascript: 'u_approver_reviewer=' + current.variables.hiddenVariable + '^ORu_secondary_approver_id_confirmation=' + current.variables.hiddenVariable;
💡 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
Thursday - last edited Thursday
I believe it should wok directly:
g_form.setValue('variable_set2_variable', g_form.getValue('variable_set1_variable'));
Please mark the answer correct/helpful accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
Hi @Jeya priya ,
To pass or copy a value from one variable set to another in a Service Catalog form, here’s how you can achieve that:
Method: Using Catalog Client Script (onChange or onLoad)
Identify the Variables:
Suppose you have a variable named requestor in Variable Set 1.
You want to copy its value into a variable in Variable Set 2, say requestor_copy.
Create a Catalog Client Script:
Type: onChange or onLoad
Script to copy value from one variable to another:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Copy requestor variable value to the variable in second variable set
g_form.setValue('requestor_copy', newValue);
}Assign this script to trigger onChange of the requestor variable.
If you want to copy it right when the form loads, you can use an onLoad client script:
function onLoad() {
var requestorValue = g_form.getValue('requestor');
g_form.setValue('requestor_copy', requestorValue);
}Make sure the variable names (requestor and requestor_copy) used in the script are the exact internal names scoped to your form.
The variables don't need to be in the same variable set; the script works across the entire catalog item form.
This approach is purely client-side and runs on the user's browser as they interact with the form.
If it is helpful, please hit the thumbs button please mark the answer as correct based on the impact!!
Kind Regards,
Shaik Mohammed Mustaq
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
why to have 2 variables to store same value?
why not show the variable to agents who work?
What business requirement it serves to copy the same value?
You can use after insert BR on sc_req_item to copy the variable value
Condition: current.cat_item.name == 'Your Item Name Here'
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.variables.variable2 = current.variables.variable1;
current.setWorkflow(false);
current.update();
})(current, previous);
💡 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
Thursday
I have two variable sets in my catalog item:
Variable Set 1 – Requestor details
Variable: requested_for (Reference → sys_user) and other details to auto populate.
→ This field is auto-populated with the logged-in user but can also be changed manually.
Variable Set 2 – ID Confirmation (Multi-Row Variable Set)
Variable: reg_id (Reference → u_reg_id table)
In the u_reg_id table, we have the following fields:
u_reg_id (String, e.g., "Reg001")
u_approver_reviewer (Reference → sys_user)
u_secondary_approver_id_confirmation (Reference → sys_user)
Goal
Inside the MRVS, the reg_id reference field should display only those records from the u_reg_id table where the user selected in requested_for matches either:
u_approver_reviewer, or
u_secondary_approver_id_confirmation
In other words:
When requested_for = John Doe, the MRVS reg_id dropdown should show only Reg IDs where John Doe is listed as either the approver reviewer or the secondary approver.
