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  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can create onLoad Catalog Client Script or Catalog UI Policy which

Applies to Catalog Task - true

In Catalog UI Policy condition check the task short description is not your specific task description

Based on that add Catalog UI Policy Action and make the variables display = false

Regards
Ankur

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

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  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

I have another related question to this.

This specific variable is also present on the order form, and I don't want it there but only visible in the catalog task.

How to hide it from the order form ?

Thanks.

Hi,

then create catalog client script or catalog UI policy which works on Catalog Item view only and then hide it

Regards
Ankur

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