Hiding Multi-Row Variable Set Variables - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Hi there,

 

A lot has been written on Multi-Row Variable Sets, some great resources out there. Some popular questions remain unanswered though, or: just not possible. One of these questions: "Hiding variables within the Multi-Row Variable Set". With the Quebec-release, this is now possible!

Hiding a Variable [Pre-Quebec]

Usually one would hide Variables through either Catalog UI Policy in combination with Catalog UI Policy Actions or through Catalog Client Script. For Multi-Row Variable Sets, up to the Paris-release scripting like g_form.setVisible() or wouldn't work. Also applying the Visible field on Catalog UI Policy Actions was read-only on purpose.
So short answer up to the Paris release, hiding a variable within a Multi-Row Variable Set: not possible.

 

find_real_file.png


Quebec-release

The Quebec Service Catalog release notes mentions:

Enhancements for a multi-row variable set (MRVS)
• Hide a variable in the MRVS so the question does not appear to users.


Hiding a Variable [Post-Quebec]

So let's dig into this! My first thought was, is the read-only field now usable on Catalog UI Policy Actions on Multi-Row Variable Sets? Yes, it is!

 

find_real_file.png

 

My second thought was, could you also use scripting like g_form.setVisible() within Catalog Client Scripts on Multi-Row Variable Sets? Well, we need to test this. Previously you could also script this though it would simply not work.

The first test case is a simple Catalog UI Policy with a Catalog UI Policy Action.

 

find_real_file.png

 

The second test is a Catalog Client Script using g_form.setVisible().

 

find_real_file.png


Result

In both cases, the end result is exactly the same. Both work as expected! Oke, it's a simple test. Though you could think of situations where you have a more complicated Catalog Item and Multi-Row Variable Set, having dependencies on which variables to display, etcetera. Though basic mechanism which we need for this works like a charm.

 

find_real_file.png

find_real_file.png

---


And that's it actually. Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Platform Architect @ Quint Technology

1x ServiceNow Developer MVP

1x ServiceNow Community MVP

---

LinkedIn

Comments
Joel15
Kilo Contributor

I am currently trying to hide a field on a multi row variable set. I am currently on Paris.

 

I am trying to hide Sub issue below if ECA is selected:

find_real_file.png

 

I have tried client script and UI policy but cant seem to make it happen!

 

Any help appreciated thanks!

 

I tried the option above no luck.

 

Also tried the following on a script:

 

function onChange(control, oldValue, newValue, isLoading) {

   if (isLoading || newValue == '') {

      return;

   } 

   //Type appropriate comment here, and begin script below

            var issueType = g_form.getValue('issue');

            if(issueType == 'ECA - Employee Corrective Action'){

         g_form.setDisplay("category",false);

            }

}

 

Thanks!

Mark Roethof
Tera Patron
Tera Patron

Hi there,

On Pre-Quebec hiding a Variable within MRVS: just not possible.

Kind regards,
Mark

Joel15
Kilo Contributor

Perfect! Thank you!

paulcagney
Tera Contributor

Thanks Mark for this.  Great to see this functionality.

I have a question.  Whilst this is great from the 'Add Row' point of view, do you know if the is a way to hide the variables (e.g. Question 1 in green box) from the catalog page?

 

find_real_file.pngCheers,

Paul

Sukhbir Singh2
Mega Guru

Hi Marc

Thanks for this article.

Is there a way to do bulk updates on a multi row variable like we do on the list view of a table?

When the number of rows are large, it becomes hard for the user to open each row and update it.

NBeheydt
Tera Expert

Is is possible to hide the entire variable set (i.e not just the variables in the set)?  I don't want it to show up at all on the portal for the end user but need it to show up on the requested item.

 

Thanks

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Never tried, though theoretically I would think this should be possible. Just give it a try.

Kind regards,
Mark

Sukhbir Singh2
Mega Guru

NBeheydt

You can create a Catalog UI Policy and hide the variable on the portal.

Check the option "Applies to a Catalog Item view" on the catalog UI policy.

Create a Catalog UI policy action to hide the variable.

 

Please mark my answer as helpful/correct if it works.

NBeheydt
Tera Expert

Yes, I tried that but all it does is hide the individual variables in the variable set.  It doesn't hide the actual variable set.

 

 

Mark Roethof
Tera Patron
Tera Patron

It works fine here (tested on Rome). Can you share in exact detail what you tried and is not working (for example screenshots)?

Kind regards,
Mark

NBeheydt
Tera Expert

Here are screenshots of the UI Policy and how the variable set still shows up.

F Walker
Tera Contributor

Hi Paul.  Did you ever get an answer to your question?  I too am trying to hide a variable from the grid view but I need it to show in the edit/add view of the row.

NBeheydt
Tera Expert

After some more digging I was able to figure this out from this post.  

Conditional visible Multi-Row Variable Set - Developer Community - Article - ServiceNow Community

The key is to add the UI Policy to the catalog item, not the variable set.  When adding the UI Policy action, select the variable set.

Manisha Kumari
Giga Expert

Hi Mark,  

Scenario: our MRVS is auto-populated with four values., Is there a way to hide the next rows based on values selected in the previous row?

Thanks,

Manisha

Troya1
Mega Guru

@Mark Roethof @Mark Roethof 

Can you or someone else from the team please advise on the question above?  

The UI policy does what it is supposed to do; however, the grid still shows.

 

Manikanta Vasa1
Tera Contributor

@Mark Roethof , can we hide a variable in MRVS based on the variable outside the MVRS?

 

i tried hiding based on a check box using client script, but not worked.

 

Any help greatly appreciated.

 

Thanks,

Mani.

Edxavier Robert
Mega Sage

@Manikanta Vasa1 

 

Can you paste you script to take a look?

Manikanta Vasam
Tera Explorer

Hi @Edxavier Robert ,

 

Based on a check box on the form, I wrote the below onChange client script. I have 2 variable in the MRVS. When checkbox is marked, I need one variable to be visible and one to be hidden and vice versa. find the script below.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}


if(newValue == true){
g_form.setDisplay('mailbox_accessType_1',false);
g_form.setDisplay('mailbox_accessType_2',true);
}else{
g_form.setDisplay('mailbox_accessType_2',false);
g_form.setDisplay('mailbox_accessType_1',true);
}

}

 

 

Thanks,

Mani.

suvro
Mega Sage
Mega Sage

That was great !!!

 

But how to hide a variable of multi-row variable set based on variable value which is not part of the multi-row variable set.

sonali jori2
Tera Contributor

@Mark Roethof  Hi, we are using one MRVS for three to four catalog item. but i want to hide some variables for one catalog only. how can we achieve this?

Version history
Last update:
‎08-03-2024 07:04 AM
Updated by:
Contributors