How to pass a value from one variable set to another variable set in catalog form

Jeya priya
Tera Contributor

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

1 ACCEPTED SOLUTION

@Jeya priya 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@Jeya priya 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

kaushal_snow
Giga Sage

@Jeya priya ,

 

By using a Catalog Client Script (for example, on Load or on Change) to read the source variable with g_form.getValue('source_var_name') and then write it into the target variable inside the other variable set with g_form.setValue('target_var_name', value) (and if you’re working with a multi row variable set you may need to reference parent.g_form or expose the main g_form in a global script so the MRVS can access it)........

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/