logo

NJP

[SOLVED]: - Dependent variable on Catalog item using Lookup Select Box

Import · Jun 12, 2020 · article

I have been looking through the WIKI/community and it seems like people are very much in dark when it comes to dependent variables in Catalog Items (service Catalogs).

There are actually two ways /scenarios to achieve this:

  1. Dependent variables on two tables.
  2. Dependent variables on single table.

Let us here talk on both with a simple example as below:

Consider there is a table called Customservers, which holds the server details and then other table called customProfiles, which would hold the profiles on each server defined in Customservers table.

image

Now, we have a Catalog item with two variables as below

Scenario here is, if you choose server, respective profiles on the server will be loaded in profiles. For now, we have defined four servers (server1, server2, server3 and server4). Each of them has some profiles defined except server4. Therefore, when user chooses out of first three servers, respective profiles would be visible and when user chooses server4, no profile will be available.

image

Profiles Table Data: -

image

  1. Dependent variables on two tables.

Catalog Variable updates as below: -

------------

Variable: - Server

Question: - Server

Name: - server

Type: Lookup Select Box

order: - 100

Lookup from table: Application [customServer]

Lookup value field: Sys ID

Lookup label field(s):u_ServerName

Include none: true

Unique values only: true

Reference qualifier:

Variable attributes:

------------

Variable: - Profiles

Question: - profiles

Name: - profiles

Type: Lookup Select Box

order: - 200

Lookup from table: Application [customProfile]

Lookup value field: profile

Lookup label field(s):

Include none: true

Reference qualifier: javascript:'u_server=' + current.variables.server

Variable attributes: ref_qual_elements=server

------------

Results: -

image

image

image

2. Dependent variables on single table.

------------------------------

Variable: - Server

Question: - Server

Name: - server

Type: Lookup Select Box

order: - 100

Lookup from table: Application [customProfile]

Lookup value field: server

Lookup label field(s):

Include none: true

Unique values only: true

Reference qualifier:

Variable attributes:

 ----------------------------

Variable: - Profiles

Question: - profiles

Name: - profiles

Type: Lookup Select Box

order: - 200

Lookup from table: Application [customProfile]

Lookup value field: server

Lookup label field(s): u_profiles

Include none: true

Reference qualifier: javascript:'u_server=' + current.variables.server

Variable attributes: ref_qual_elements=server

--------------------------------

Results: - Would be Same here as well.

View original source

https://www.servicenow.com/community/developer-articles/solved-dependent-variable-on-catalog-item-using-lookup-select/ta-p/2324503