Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

"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

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

Thanks