MultiRow Variable set is not populating the values in the variable

ponmudi
Tera Contributor

i am developing a catalog client script to populate values based on gliderecord query against the snow table. It could print the value as expected. In console.

However, when i try to setValue based on the result, its not updating in the MRVS. 

My Varaibale set name is ServerNameListPopulate
My Variable set internal name is servernamelistpopulate

My variable name is sys_id, its a reference type to the system table (cmdb_ci_win_server)

My Catalog client script

function checkServer(gr2) {

while (gr2.next()) {
//console.log("server :" + gr2.child);
var gr3 = new GlideRecord('cmdb_ci_win_server');
gr3.addQuery('sys_id', gr2.child);
gr3.query(getServerfqdn);
}

function getServerfqdn(gr3) {
var output = [];
while (gr3.next()) {
console.log("server :" + gr3.fqdn);
var obj = {};
obj["sys_id"] = gr3.fqdn;
output.push(obj);

}
console.log("output is: " + JSON.stringify(output));
console.log("output is: " + JSON.stringify(obj));
g_form.setValue('servernamelistpopulate', JSON.stringify(output));

}
}



What's the mistake here? Loop? or anything else? like set value?

6 REPLIES 6

KP27
Tera Contributor

You only need the key:value pair to auto-populate the MRVS. In the script include use this
var obj = {'mrvs_variable_name':value to be set.toString()};

var arr = [];

arr.push(obj);

return JSON.stringify(arr);

KP27
Tera Contributor

Instead of using GlideRecord in your client script, call a script include.
In the script include create a JSON object where the name of the keys matches with the name of the variables in the MRVS.
Return this JSON object as a string using JSON.stringify(name of your JSON object)