How To Make A Field Dependent On A Service Catalog Item.

reyservicenow
Tera Expert

How To Make A Field Dependent On Another Variable On A Service Catalog Item. Not In A Form.

1 ACCEPTED SOLUTION

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

You didn't mention the type of fields you are referring to, but if a choice/select box, this article will walk you through it:


http://wiki.servicenow.com/index.php?title=Adding_Dependent_Variables#gsc.tab=0


View solution in original post

9 REPLIES 9

I finally got this to work when I quit copying an pasting and stepped back in frustration.


Then I realized that ServiceNow uses current.variables.VARIABLE-NAME, not current.variable.VARIABLE-NAME.


That simple change made this work perfectly for me.


Paul Bloem
Tera Expert

Hello, I realize this question has been posted for a while, but I found a new way to do this that's a bit hacky and at least doesn't require any additional tables to be created or a lot of code to be written. I haven't thought too long and hard about whether there are any major downsides to doing this either, so be careful I suppose.

The process is:

  1. Create the parent variable as a "Select Box" field and enter all of your values.
  2. Create the child variable first as a "Select Box" and create all the child values, making sure that the "value" for each option starts with the parent value you want it dependent on.
  3. Once you have all the values entered, change the type of the child variable to "Reference" and enter the following in the Type Specifications:

    - Reference: "Question Choice [question_choice]"
    - Use reference qualifier: Advanced
    - Reference qual: javascript:"question=<sys_id of current variable record>^valueSTARTSWITH" + current.variables.<name of parent variable>

    For example:

You'll need to remember (maybe add some documentation?) to change it back to a select box if you need to add any other options, or tweak the logic for when to show the choices related list so it shows in this new situation.

You don't get a normal dropdown in the service catalog view, but it works, and it's very nice in the Service Portal.

This was immensely helpful. Probably the best and easiest experience you can get that's not licensing out tables or flooding the item with custom code.  

Snehal2
Kilo Guru

Here is the blog post I have written that can help you. Dependent catalog variables can be created in two ways. 

https://community.servicenow.com/community?id=community_article&sys_id=ed94c724db75c410feb1a851ca961...

Hit Like if this helps you!

Regards,

Snehal

Kailash Bhange
Kilo Sage
Kilo Sage

Hi All,

Please take a look at Article below:

1. dependent on single table
2. dependent on two tables using referene

[SOLVED]: - Dependent variable on Catalog item using Lookup Select Box
https://community.servicenow.com/community?id=community_article&sys_id=1ce7dceedb5914101cd8a345ca961952

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Thank you!
Regards,
Kailash.