Pre-populate 3/4 Rows in MRVS When catalog item is loaded on portal

Divya Dahate
Tera Expert

Hi All, 

 

Can we Pre-populate 3/4 Rows in MRVS When catalog item is loaded on portal?

I received a requirement where i need to show 3/4 pre-populate rows with values in MRVS (Multi Row Variable set) and last two columns should be editable.

I'm not able to find the solution for this can you please suggest something to achieve this requirement.

 

 

Thank you!

2 ACCEPTED SOLUTIONS

@Divya Dahate 

then simply form the json and set

something like this

var arr = [];
// give the correct variable names within MRVS and the correct values
var obj = {"variable1":"hello","variable2":"bye"};
arr.push(obj);

var obj1 = {"variable1":"hello1","variable2":"bye1"};
arr.push(obj1);

var obj2 = {"variable1":"hello12","variable2":"bye12"};
arr.push(obj2);

g_form.setValue('mrvsVariableName', JSON.stringify(arr));

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

View solution in original post

Hi @Ankur Bawiskar

 

Thanks again for respond.

 

I wrote this below script and it's working as i see alert msg when form is loading but this script not setting the value in MVRS 

 

function onLoad() {
    alert("Test");
    var arr;
    arr = [];
    var obj = {
        "dimresourcegroupid": "12345",
        "cloudprovider": "azure",
        "subscription": "Prod-03",
        "resource_group": "StarSchema-01",
        "billing_notification_group": "DevOps",
        "percentage_cost_change": " ",
        "daily_cost_threshold": ""
    };
    arr.push(obj);
    var obj2 = {
        "dimresourcegroupid": "12346",
        "cloudprovider": "azure-2",
        "subscription": "Prod-03-2",
        "resource_group": "StarSchema-01-2",
        "billing_notification_group": "DevOps-2",
        "percentage_cost_change": " ",
        "daily_cost_threshold": ""
    };
    arr.push(obj2);
    alert('Arr: ' + JSON.stringify(arr));

    g_form.setValue('thresholds', JSON.stringify(arr)); // Alsotried setDisplayValue
}
What can i try to set value's in MVRS?
 
DivyaDahate_0-1734075264120.png

This type of JSON is we are getting. on alert body.

 

 

Thank you!

 

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Divya Dahate 

yes you can use onLoad catalog client script and use GlideAjax if you wish to bring some information from table and set the JSON string

what script did you start with and where are you stuck?

I shared solution few years ago, check and enhance

How to auto-populate Multi-Row Variable Set? 

check this link as well

How to auto populate project details in a multi row variable set 

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

Hello @Ankur Bawiskar , 

 

Thank you for the respond, 

i don't have values in any table but my client provide me an value's for those variables, In that can what should i do?

and the for some variable's (field's) client want them as editable, So can you please suggest on the same.

@Divya Dahate 

then simply form the json and set

something like this

var arr = [];
// give the correct variable names within MRVS and the correct values
var obj = {"variable1":"hello","variable2":"bye"};
arr.push(obj);

var obj1 = {"variable1":"hello1","variable2":"bye1"};
arr.push(obj1);

var obj2 = {"variable1":"hello12","variable2":"bye12"};
arr.push(obj2);

g_form.setValue('mrvsVariableName', JSON.stringify(arr));

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

Hi @Ankur Bawiskar

 

Thanks again for respond.

 

I wrote this below script and it's working as i see alert msg when form is loading but this script not setting the value in MVRS 

 

function onLoad() {
    alert("Test");
    var arr;
    arr = [];
    var obj = {
        "dimresourcegroupid": "12345",
        "cloudprovider": "azure",
        "subscription": "Prod-03",
        "resource_group": "StarSchema-01",
        "billing_notification_group": "DevOps",
        "percentage_cost_change": " ",
        "daily_cost_threshold": ""
    };
    arr.push(obj);
    var obj2 = {
        "dimresourcegroupid": "12346",
        "cloudprovider": "azure-2",
        "subscription": "Prod-03-2",
        "resource_group": "StarSchema-01-2",
        "billing_notification_group": "DevOps-2",
        "percentage_cost_change": " ",
        "daily_cost_threshold": ""
    };
    arr.push(obj2);
    alert('Arr: ' + JSON.stringify(arr));

    g_form.setValue('thresholds', JSON.stringify(arr)); // Alsotried setDisplayValue
}
What can i try to set value's in MVRS?
 
DivyaDahate_0-1734075264120.png

This type of JSON is we are getting. on alert body.

 

 

Thank you!