We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Hide variables that weren't filled in the request in Workspace

AnaLucíaR
Tera Contributor

Hi everyone,

I’m working with a catalog item that contains a large number of variables and many different scenarios. Because of this complexity, creating multiple UI Policies to control the visibility of variables in Workspace would become very difficult to manage.

As an alternative, I’m considering implementing a Client Script that hides variables in Workspace when they were not filled out in the request.

Has anyone implemented something similar before, or can suggest a better approach to handle this scenario?

Any recommendations or best practices would be greatly appreciated.

Thanks in advance!

2 REPLIES 2

Tanushree Maiti
Giga Sage

Hi @AnaLucíaR 

 

1. Create a display Business rule

Refer for code :https://www.servicenow.com/community/developer-forum/how-to-hide-empty-variables-of-ritm-and-task/m-...

 

2.Create aOnLoad  Catalog Client script to hide Variables (Applies to RITM & SCTASK):

 

function onLoad() {

    //Hide all empty variables using the scratchpad of Display business rule

    if(g_scratchpad.emptyVars != ''){

          var emptyVars = g_scratchpad.emptyVars.split(',');

          for(i = 0; i < emptyVars.length; i++){

                g_form.setDisplay('variables.' + emptyVars[i], false);

          }

    }

}

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Ankur Bawiskar
Tera Patron

@AnaLucíaR 

I created blog for this 5-6 years ago, see that and enhance it for your requirement

Hide empty variables on RITM and TASK record 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader