Hide variable on multi row variable set

KaMmILa__
Tera Expert

I have a Multi-row variable set which I am using in a catalog item , how to hide a variable on that , I am not able to hide the Variable Using UI policy as the visible is grayed out

 

find_real_file.pngI also created a onload cS still not working 

find_real_file.png

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Eg: I have location reference variable on my MRVS then I added location table to match it .

Quick Demo

 

 

find_real_file.png

 

Hope it will help you. 

View solution in original post

23 REPLIES 23

Michael Jones -
Giga Sage

Unfortunately, it's not an option in an MRVS: 

You can define catalog client scripts, catalog UI policies, and catalog data lookups for a multi-row variable set. But, you cannot edit the visibility settings of its variables using catalog client scripts and catalog UI policies, that is, the g_form.setVisible() is not honored in catalog client scripts, and the Visible field of a catalog UI policy action is read-only and set to Leave alone.

https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/service-catalog-manage...

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Thanks Michael 

The issue we are facing is we are trying to report on the MRVS by creating a database view , but we have a reference field where in that report we are only getting the sys_ID , one of the community member suggested to use the string field and copy the reference field value to the string field ( which is working fine ) but the issue is we cannot have 2  same fields on the form , Is there any alternate solution for this?

 

ref this is what we followed

https://community.servicenow.com/community?id=community_question&sys_id=252bce56dbd363809a64e15b8a961921

So...I'm not fan of DOM manipulation in general, but as long as we're not drastically altering elements in a way that might break them it's generally ok for one-off situations like this. That being said, there is a way you could do it, with a little extra work. 

First you will need the sys_id of the variable you want to hide, along with the name of the variable.

You will also want to make sure that the variable is at the bottom of the list in the variable set as what I can show you will make it not visible, but it will still take up space in the layout. 

Then, a script like this onload in the variable set should do the trick - just replace the name and sys_id and give it a go!

You will need to set isolate script for this one to false (unchecked) - if that is not on the form for your client script, you can add it to the list view and set it there. 

function onLoad() {
    //Type appropriate comment here, and begin script below
    var sys_id = '1afe7f2b07b1a010c5cff1e08c1ed061'; //populate with your variable sys_id
    var field_name = 'text'; //populate with your variable name

    if (window === null) {
        //we are in the Service Portal so we use jQuery
        setTimeout(function() {
            this.jQuery("#" + field_name).hide();
        }, 500);
    } else {
        //We are in the UI so we use getElement
        g_form.getElement('IO:' + sys_id).style.display = "none";
        g_form.getElement('variable_IO:' + sys_id).style.display = "none";

    }

}

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Thank you so much, Michael, The variable is hiding on the form even though I applied that on Request item , the values are still showing 

RITM: variables 

find_real_file.png

 

find_real_file.png