how to hide variables in a multi-row variable set ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2019 12:47 PM
I need to show and hide variables based on choice list options selected in a mmulti-row variable set, can anyone suggest any altrnate for this as Servicenow has made the UI Policy action option "Visible" locked out for Multi-row variable set, nor is the g_form.setDisplay('field_name', false); working on this type of variable set.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 03:47 PM
Can you provide the script you used to copy the first MRVS to the second one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2020 10:02 PM
You can write the on-submit client script to copy from one MVRS to other like below.
1) Get the values from MRVS1 and convert it as array to process easily
var mvrs1_array ='';
var multirow_variableset_rows=g_form.getValue('mrvs1');
if(multirow_variableset_rows !='[]'){
mvrs1_array=JSON.parse(multirow_variableset_rows);
}
2) Now we have to create an array of object which have the fields of MVRS2
var object ={};
var mvrs2_array=[];
for( i=0;mvrs1_array.length>i;i++){
object ={};
object.var1= mvrs1_array[i].var1;
object.var2= mvrs1_array[i].var2;
object.var3= mvrs1_array[i].var3;
object.var4= '';
object.var5= '';
mvrs2_array.push(object);
}
3) Now convert the array into JSON object and set the variable 2 value
var mvrs2_json=JSON.stringify(mvrs2_array);
g_form.setValue('mrvs2',mvrs2_json);
Hope it will be helpful 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2019 08:34 AM
You can achieve this using DOM
i have hide it refer below SS:
Refer below code:
function onLoad() {
//Type appropriate comment here, and begin script below
//table: id="31a5d7f71b6440109998da49cc4bcbca_table"
var tbl = document.getElementById("31a5d7f71b6440109998da49cc4bcbca");
var col = tbl.getElementsByTagName('th')[2].style.visibility="hidden";
}
this is a catalog onLoad client script
incase you need any help writing script let me know
If this resolves your query, please mark my comments as correct and helpful
.
Regards,
Ajay Chavan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 08:25 AM
Hi Ajay,
I tried to reproduce this using the element ID using the browser console, but no other changes. It didn't seem to work for me.
Here's where I got the table ID:
Here's the script as I tried it:
function onLoad() {
//Hide Multi Row Variable - this uses DOM manip, but is currently the only known way to conditionally hide a Multi Row Variable from a Catalog Item or Record Producer
//table: id="e4b8ae051b0898142457dac2cd4bcbcd_table"
var tbl = document.getElementById("e4b8ae051b0898142457dac2cd4bcbcd");
var col = tbl.getElementsByTagName('th')[2].style.visibility="hidden";
}
What am I doing wrong? Am I using the wrong element ID?
Thanks,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 08:45 AM
LOL Nevermind. Conditionally hiding a multi row variable set with a Catalog UI Policy was actually pretty straightforward. No need for DOM manip. SN discourages that anyhow.
Maybe it was updated in New York...
Regards,
Robert