Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Is it possible to hide variable container in requested item [sc_req_item] form using a client script?

abrahams
Kilo Sage

With Service Catalog requested item I've tried different ways to hide the container in the requested item form but none of my attempts have worked. I seem to be able to hide other variables but I am having problems finding a way to hide containers. I would like to show/hide them based on specific criteria. Would anyone know the trick to hiding containers in a requested item form?

Syntax that I've tried:
g_form.setDisplay('variables.container name',false);
g_form.setVisible('variables.container name',false);

6 REPLIES 6

justin_drysdale
Mega Guru

I have found that it is hard to script against containers. As a rule I use labels now. 😄


PANKAJ MAHTO1
Tera Expert

Hi Team,

 

Yes !!!! We can Show/Hide "Container Start" Variable' Display Value for a Catalog Item in Portal.

Note:- I have fixed by Using "UI Policy Script" and "UI Policy Action".

1. Create an UI Policy as per your condition to Show/Hide the "Container Start" field LABEL.

2. Write below Script Together on Script Part-

 

SCRIPT:-

function onCondition() {

g_form.setDisplay('variables.high_performance_computing_linux_unix_ah', false)// Enter the Value of the Variable.
}

find_real_file.png

3. Create UI Policy action for the "Container Start" variable and Make below changes

 

A). Mandatory = FALSE

B). Visible = FALSE.

 

find_real_file.png

 

RESULT:- Now Based on condition. "Container Starts" field Label can be Show/Hide.

************************************************************************************************************************************************************

Example:-

Before Condition Fulfilled- "Container Start" Variable Field Label "High Performance Computing" Can bee seen.

find_real_file.png

 

AFTER CONDITION MATCHED:-

 "Container Start" Variable Label is HIDDEN-

 

find_real_file.png

 

Important:- "Container End" Variable Should be Just after "Container Start" Order. You May adjust later for other variable with New Container Start but to Achieve this you have to Create 1-1 (Container Starts && Container End).

find_real_file.png