"current.variables" use in Reference qualifier in MRVS is not working

Dinh Nguyen
Kilo Sage

I create a variables "NON EXT T" in MRSV use Reference Qualifier : javascript:'u_incident=' + current.variables.u_incident_t; as below:

DinhNguyen_0-1698901488855.png

 

 

The data like this :

DinhNguyen_1-1698901488968.png

 

In the Record Producer, When i choose Incident T(u_incident_t) = "INC0010019", it's should show 2 record TESN0001024TESN0001023, but it's not ! Please help me ! Thank you so much

DinhNguyen_2-1698901488835.png

 

DinhNguyen_3-1698901488861.png

 

 

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hi @Dinh Nguyen 

 

Unfortunately current.variables will not work in reference qualifier in MRVS.

 

This is how we achieved it using  gs.getSession();

 

Use Case : We have  catalog item having 

A. Variable on Catalog form

    Type   : Reference  => User (sys_user) table

    Name : Requested for

 

B. MRVS contains below variable 

     Type   : Reference  => Hardware (alm_hardware) table

    Name : Asset id

 

So, depending upon Requested for "hardware" related to him should get populated in MRVS variable "Asset id"

 

VishalBirajdar_0-1698903197218.png

 

Solution : 

 

Step 1 : Create client callable script include to store session data

 

 

/*Function to get session details*/
 setSessionValues: function() {
        var user = this.getParameter('sysparm_user');  
      
	var session = gs.getSession();
        session.putClientData('requested_for', user);
        var clientData = session.getClientData('requested_for');  //this will be used in reference qualifier
        gs.info(clientData);

		return clientData;
    },

 

 

 

Step 2 : Write onLoad client script in MRVS

** onLoad client script should be in MRVS

 

 

function onLoad() {
    /*Get Requested for from Catalog form*/
    var req_for = g_service_catalog.parent.getValue('requested_for');

    /*Call GlideAjax and store the session Value*/
    var grSession = new GlideAjax('MVRS_Session');   //script include name
    grSession.addParam('sysparm_user', req_for);    // 
    grSession.addParam('sysparm_name', 'setSessionValues');

	grSession.getXMLAnswer(callback);
	
	function callback(answer){
		g_form.addInfoMessage('answer=' + answer);
	}

}

 

 

 

Step 3 : Add reference qualiifier

 

 

javascript:'assigned_to=' +session.getClientData('requested_for')

 

 

 

VishalBirajdar_1-1698903502661.png

 

     

 That's it....!!!

 

You can adjust your code,variables as per your requirement...!!

 

Hope this helps...!!!

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

6 REPLIES 6

Shruti
Mega Sage
Mega Sage

Hi,

This is the limitation of MVRS. Variables outside MVRS can't be used in reference qualifiers

Use below to pass main variables value to MVRS

g_service_catalog.parent.getValue("your_variable")

https://www.servicenow.com/community/developer-articles/create-dynamic-multi-row-variable-set-form-b... 

Thanks @Shruti   for reply me,

I was tried ! But it's still not working

javascript:'u_incident=' + g_service_catalog.parent.getValue("u_incident_t");

Hi,

It will not work in reference qualifier.

Use it in client script

Community Alums
Not applicable

Hello @Dinh Nguyen ,

 

You cannot use variables that are not part of mrvs in the reference qualifier.

 

AnandMahajan_0-1698902340658.png

 

If this solves your query, mark this as helpful and correct.

 

Thanks

Anand