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

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.


Hi WIlliam,



I have the same problem and your solution doesn't help me.



I want a variable called fqdn to hide during creation and it should be mandatory when closing the task,


Try this.


Create the variable in the Item definition, let's say "fqdn".



Create a Catalog UI Policy for the item as follows:


Applies to: A catalog item


When to apply conditions: leave blank


Applies on Catalog item view: true


Applies on Catalog tasks: false


Applies on Requested item: true


On load: true


Reverse if false: true



Then you create one Catalog UI Policy action for this Catalog UI Policy:


Variable name: fqdn


Mandatory: false


Visible: false


Read only: leave alone



They way you would read this is, whenever you try to view this variable from the Catalog item view (when it's being requested) or from the Requested item view (from the RITM form), make this variable not visible and not mandatory, otherwise make it visible and mandatory.



Give that a shot and let me know.


Brainy !!! let me try and let you know


i have always had issues with the entire policy action thing.. keeping track of which one is on which variable.. so i can ensure i dont' have multiple policies that step on each other and troubleshooting when they do.. SOOOOO...



heheh i created a relationship and added the related list to the catalog variable form.. you might find this usefull..



RELATIONSHIP:



Name:     UI Policy Action --> Variable


Applies to Table           Variable[item_optoion_new]


queries from table[caalog UI Policy Action[catalog_ui_policy_action]



query with:



var qstring='IO:' + parent.sys_id;


current.addQuery('catalog_variable', qstring);




_____________________________________________________________



what this does is provide you a related list on your catalog variables of all of the UI Policies that affect THAT variable... now if it doesn't behave right i can troubleshoot the UI policies easily .. and if i have a new variable i need to behave the same... it is easy t implement.




I did the same thing to fields <non catalog> so i can find the regular UI polices that affect a field on a form.. which is kinda handy also.