MultiRow Variable set is not populating the values in the variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 04:29 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2023 04:47 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2022 05:35 AM
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)