The CreatorCon Call for Content is officially open! Get started here.

Applying UI Policies to Variable Editor

ljschwaberow
Giga Expert

I read the post below regarding adding a Business rule and Client script to filter out empty variables, so they won't show up under Variable Editor. UI policies on record producers should be applied on incident form variable editor. This works great if you have a free form text field. However, most of my UI policies apply to Yes/No Variables showing up under certain conditions. Such as:

If 'My Computer' is selected from a list, a 'Are you having a problem with a specific applications?' shows up with Yes/No choices. Is there any way to keep this field from showing up on the Variable Editor if say 'My Printer' is chosen in the beginning instead of 'My Computer'?

1 ACCEPTED SOLUTION

Yes, basically you build an if on the "request_type" you provide.



So in my example, we have a record producer that firsts ask the user what type of issue they are having:



emailtype.png



Then based on how they answer this question we ask them some additional questions.   Most are not related at all to email.   Then in the script section I have created an if for each value if they have answered Desktop, Email, Printer or Phone.   And based on how they answer those questions, I populate the correct information into the work notes.



Here is a full snippet of the code that just handles that:



recordproducercode.png



The final line of code basically would be the following:



current.work_notes = descriptionarray;


View solution in original post

14 REPLIES 14

I may be misunderstanding or missing something, but I have been using this for five years and I don't know what an Incident Variable Editor is (on a form). Can you please take a screen shot of one? To me a service catalog item (record producer) has variables, and a form has fields.



Everything in you say starting with "I am implementing..." makes sense, and yes the incident form does not obey catalog UI policies, only regular UI policies. So I would think that you should also have UI policies on the incident form if you want to hide fields the same way you were hiding variables on the record producer.



But I don't think of an incident form as having any variables on it.


No worries


Here is a screen shot of the Self Service View of our incident form. Starting with 'Issue Details' and lower are all variables I created. Everything above that is the fields you were describing. To add the variables from my Record Producer to this view I had to select the Incident Variable Editor under 'Personalize Incident Form'. I have included an image of this as well.


find_real_file.png



find_real_file.png


Ok, I see.



I wouldn't put the Incident Variable Editor on the Incident Form. As far as I know that is unusual behavior. The OOB incident form does not do this. The ServiceNow wiki says: "When ordering an item in the service catalog, the information collected from variables on the item form is normally transferred into a different record". There is also the added problem of possible conflicting names between fields on your form and variables on the Variable Editor.



I recommend that upon submit that you capture the information submitted by the user into fields somewhere on the incident table, and I would simply show those fields on the form. Then you can use UI Policies to show or hide them as you prefer. This is our normal procedure.



But if you insist: you may have to inspect the html on your page to determine the variable identifiers and then write onload client script to hide them. This would require some knowledge of DOM manipulation because there are probably forms within forms on the variable editor.


Thanks for the recommendation Geoff! This information is being copied over to the Incident Form Work Notes for Tech Support but I did want the end user to be able to view the information they submitted in the Self Service View of the incident form if need be. Ultimately what I am trying to do is only have the pertinent fields show up in the Work Notes based on how they answered the questions. So for example one of the question is 'what device is having the issue?' if they answer 'My Computer' the UI policy prevents all the other fields from showing up. However, after they submit this all the fields are transferred to the Work Notes (even if they weren't answered. I have a script in place that prevents empty fields but this doesn't apply to the field where the answer is 'Yes/No' because an answer is selected. Perhaps an additional Client Script is all that will fix this. Thanks!


Hi Lindsey,



Review this post.   I think this might provide a possible solution:



Re: How can you show a variable from a catalog item on an Incident or Incident Task



The difference you will want to assign to current.work_notes instead of current.description.