Show and require variable in TASK, hide in catalog

grosch
Mega Expert

When the customer is submitting their catalog request item, I don't want one of the variables to display, so in the onLoad script I do this:

 

g_form.setDisplay('STT_Opera_opsTransitionLead', false);

 

When the first task is created from the workflow, I want the person who gets the TASK assigned to them to have to fill out that variable, so I created a catalog UI policy that sets Mandatory and Visible to true.   For that policy I set "Applies to Catalog Task" to true, and "Applies on a Catalog View Item" to false.

 

Finally, within the Catalog Task on the workflow editor I included that variable on the TASK display.

 

When I open that task, the variable is not displayed.   So that's problem 1.

Problem 2 is that I can "close complete" the task even though there's no value set for that variable.

 

help?

1 ACCEPTED SOLUTION

williamsun
Mega Guru

This is now (since Calgary) handled through Catalog UI Policies.


Service Catalog UI Policy - ServiceNow Wiki



You need to create a Catalog UI Policy for the item, on the form there are three check boxes:


- Applies on Catalog Tasks


- Applies on Requested Items


- Applies on Catalog Item view



Here is where you can set all of that so you don't even have to use that onLoad script to hide as you can specify all your conditions on a series of Catalog UI Policies.


Always bear in mind it gets tricky when you have several UI Policies on how to use the Order and Reverse if false field.


View solution in original post

9 REPLIES 9

Jim Coyne
Kilo Patron

Does the variable display on the Requested Item form?



The one thing that comes to mind is you may have something specified on the "Read roles" field for the variable?


Hi Jim,



unfortunately there are no read roles set.


I've discovered that any variable which is blank when the catalog form is filled out will not appear visible on the TASK, whether or not you've asked for it.   Not sure how to disable.  



In this specific case the field is a Reference to sys_user, so I set the value at startup to 'FILL ME IN' and then hide it.   Technically it has a value so it appears on the TASK form, but the field is blank as 'FILL ME IN' isn't valid.   So that solves step one (make it appear on task).



Now my only issue left is how do I ensure that they can't close the task as being complete until there is actually a value filled in there?   The UI policy marks it mandatory at that point, and I do see the red bar, but the task doesn't bother to look at the when it's being closed.


look for a BR on the catalog task form called Hide Empty Variables


this   is probrably the culprit.... keep in mind if you disable this variable you will need to come up with a way to hide any variables that are empty that   you don't WANT to show on the task form... i am thinking when we get to dublin we may need a setting for show on catalog task.. then we can use that variable with a simple yes no setting to skip that variable.