Using information in one Variable set to another variable set.

rafaelalves4337
Tera Contributor

Hello Folks,

 

I have a catalog form that has 2 variable sets, first variable set (Requested_for_details) and second variable set (computer details).

 

In my second variable set a have a reference variable called Computer_name, when the user select that variable, it must only show the computers assigned to the Requested_for user that was selected in the First Variable set (Requested_for_details).

 

I tried to do get it using reference qualifier javascript: "assigned_to=" + current.variables.requested_for

 

But it's not populating the computers, probably because it's in another variable set, can I do it using a client script? if yes, could you please give an exemple?

 

Thanks in advance.

1 ACCEPTED SOLUTION

@rafaelalves4337 

the link I shared has working solution

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

what configuration you did and what debugging did you perform?

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

View solution in original post

11 REPLIES 11

Shivalika
Mega Sage

No @rafaelalves4337 

 

It should populate, since it's still one of the variables in the form. 

 

Just add variable attribute

 

ref_qual_elememts = requested_for 

 

In your computer name reference fields since it's dynamically depending on other reference variable. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

 

Chaitanya ILCR
Kilo Patron

Hi @rafaelalves4337 ,

it should work if both the variable sets are single-row variable sets

if the "computer details" is a MVRS you can follow the scenario 2 approach in the below blog

 

https://www.servicenow.com/community/now-platform-articles/yes-you-can-effectively-set-or-update-a-r...

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hi @rafaelalves4337 ,

Like suggested in this above post you can create a onload catalog client script on the MVRS variable set

 

Script Include

var refQualUtils = Class.create();
refQualUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    setSessionData: function() {
        var catItemVarName = this.getParameter('sysparm_cat_item_var_name');
        var catItemVarValue = this.getParameter('sysparm_cat_item_var_value');
        var session = gs.getSession().putClientData(catItemVarName, catItemVarValue);
        return;
    },
    type: 'refQualUtils'
});

 

OnLoad Client Script (create on MVRS)

function onLoad() {
    var catItemVarName = 'v_manager'; //catalog item variable name
    var catItemVarValue = g_service_catalog.parent.getValue('requested_for' /* replace with your variableName*/ );
    var ga = new GlideAjax('refQualUtils'); //client callable script include name
    ga.addParam('sysparm_name', 'setSessionData'); //function in script include
    ga.addParam('sysparm_cat_item_var_name', 'requested_for');
    ga.addParam('sysparm_cat_item_var_value', catItemVarValue);
    ga.getXMLAnswer(function() {});
}

 

and update the ref qual of the variable on mvrs with 

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

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Shivalika
Mega Sage

@rafaelalves4337 

 

Just an edit to my previous reply - it's ref_qual_elements = requested_for