access variable inside MRVS

vandanasaluja
Tera Contributor

Hi team,

 

I have a variable Requested for  which is part of the User field variable set, and I have affected for the variable which is part of MRVS now i want to populate the affected for field with all users where manager is equal to requested for.

 

 

I tried creating a script include and calling it via ref qualifier but its returning undefined for current.variables.requested_for

8 REPLIES 8

Hello @vandanasaluja 

 

 current.variables.requested_for.toString();

 

Try this please.

 

Pls mark my solution as accept and thumbs up if you find it helpful. It will help other users on community to find helpful response.

 

Regards,

Samaksh Wani

Ankur Bawiskar
Tera Patron
Tera Patron

@vandanasaluja 

so you want to use outside variable within reference qualifier of MRVS variable?

refer this link and it has solution

SOLVED: Issue with MRVS multi row variable set accessing the form values 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@vandanasaluja 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

nemamuskan
Tera Contributor

Hello @vandanasaluja,

 Please try the onload script in the MRVS. Assuming that the affected user is List collector which stored the list of users with manager as the requested_for in the form. Please find the script below:

 

 

function onLoad() {
   
var v=g_service_catalog.parent.getValue("requested_for");
alert("alert"+v);
var gr=new GlideRecord("sys_user");
gr.addQuery("manager",v);
gr.query();
var a=[];
while(gr.next())
{
	a.push(gr.getValue("name"));
}
var a_to_s =a.toString();

g_form.setValue("mrvs_req_for", a);
   //Type appropriate comment here, and begin script below
   
}

Please let me know in case of any query or I need to understand the problem in different way.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Thanks,

Muskan