How to make variables only visible on specific catalog task

sacha2
Kilo Contributor

Hi,

My question seems pretty basic I guess but I need to be able to display some variables only on specific catalog tasks.

I guess I'll have to deal with catalog UI policies but I don't know where to start with this.

For example, in one catalog task I want to have this question "Do you validate the quote ?", but only in this particular CT, not anywhere else.

Is there a specific javascript chunk of code to write or it's simpler than that ?

Thanks.

1 ACCEPTED SOLUTION

Hi,

While creating Catalog Task from workflow you can ensure you show only the variables you want to be visible.

This can be done by selecting variables from Available to Selected section

OR

Sample script below if those variables are present on more than 1 task and you want to show only for 1

function onLoad() {
	//Type appropriate comment here, and begin script below

	var shortDescription = 'Your Task Short Description for which it needs to be visible';
	if(g_form.getValue('short_description') != shortDescription){
		
		// if that variable is mandatory then make it non-mandatory first
		
		g_form.setDisplay('variableNane', false);
	}

}

Regards
Ankur

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

View solution in original post

10 REPLIES 10

Aman Singh_
Kilo Sage

Hi

If You want the variable to be available only at the Catalog Task then make sure you uncheck the highlighted and checked the remaining two either in UI Policy/Client Script

 

 

Please mark Correct/helpful if applicable, thanks!!

Aman