Kailash Bhange
Kilo Sage
Kilo Sage

 

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.

find_real_file.png 

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

  1. Server
  2. Profiles

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.

find_real_file.png

Profiles Table Data: -

 find_real_file.png

 

  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: -

 find_real_file.png

find_real_file.png

find_real_file.png

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.

 

Comments
Satya8
Mega Expert

Its really helped alot for me today. But i have one question, i have one requirement, where i have category, name and Edition are three lookup select box variables. name is populate based on category(this is working fine). edition is populate based on category and name. so here how to query in the edition variable of both category and name ??

Kailash Bhange
Kilo Sage
Kilo Sage

Hello Satya,

Apologies for delay in response, i was a bit inactive on communities.

If second variable is dependent on the first you can directly use second variable as query option to make 3rd field values visible.

e.g. - 

I am considering that you are successful in making second variable(name) visible based on first.

now you only want the third variable to be visible based on second variable value(no need to consider first variable as well, because second is visible only on 1st selection).

you need to modify your second variable and use Sys_ID in Lookup value field. as in the first variable and make sure to refer attribute to second variable from the 3rd one.

 

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

Thank You!
Regards,
Kailash

daveh1
Mega Contributor

I don't think any community articles address the topic of multiple variables on ref_qual_elements very well.

The current Service catalog variable attributes doc page fails to mention that ref_qual_elements takes a semicolon separated list when you need more than one for a situation like this:

Reference qualifier: javascript:'u_server=' + current.variables.server + '^u_other=' + current.variables.other
Variable attributes: ref_qual_elements=server;other

I also think this current doc description is poor (and is echoed many places):
A list of fields to be sent back to the server to get an updated reference.

From my point of view in the SC, this really means:
Recalculate the reference qualifier when any variable in the list changes.

However, please be aware:
I have not been able to get multiple variables on ref_qual_elements to work on the Service Portal!
I had a situation with 3 variables and the ref-qualifer would only recompute when ONE of them changed.
(it did not seem to matter where/which position the variables appeared in the list,
the system only recalculated the ref-qual when one specific variable changed).

Of course the platform SC worked fine with 3 variables but, to make my code also work in SP,
I had to only specify one variable on ref_qual_elements and rearrange the catalog item so
that one variable was dependent on the other two.
It worked for me that time, but I'm not sure that would always be possible.


Lidia
Tera Contributor

@Kailash Bhange I know this is an older post, but a quick question - if working in Scoped Application I cannot use Javascript at all in my Reference Qualifier (permissions issue) so is there an alternative to javascript for the single table scenario?

 
bipin207
Tera Contributor

This was great .There were other people posted the same solution but few key details were missing which caused confusion .You provided everything which was needed to configure this. Really saved my time .thanks

 

 

yash46
Giga Explorer

Hi I tried in the same way as mentioned above but no luck.Is this version dependant or what as I am working on Quebec version.

Damian Martinez
Mega Sage

Hello Everyone,
this was a great post as I had the same requirement, configure dependant variables from two different tables it works really well. However the workflow for the item is failing because when looking up the record, the sys Id is setup in the variable:
find_real_file.png

As you can see the SysID is returned, therefore not finding the record, does somebody know how to fix this for the flow to work?

Thanks in advance!

latha13
Tera Contributor

Hi Kailash Bhange,

I have tried the same and followed same steps but unable to achieve this scenario.

 

Kailash Bhange
Kilo Sage
Kilo Sage

Hello, Nope it is not the version dependent.

Kailash Bhange
Kilo Sage
Kilo Sage

can u pls confirm if u are doing it in custom scope ?

KoenHaemels
Tera Contributor

Hi

I've tried to apply a 3th Lookup select box that is based on the 2nd variable.
Like you've told i had to change the Lookup value field to Sys_ID and make sure to refer attribute to second variable from the 3rd one. But it return me a single value, while it should return 4 values.


So it would be like this:

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: Sys ID
Lookup label field(s): u_profiles
Include none: true
Reference qualifier: javascript:'u_server=' + current.variables.server
Variable attributes: ref_qual_elements=server
 ----------------------------

Variable: - Rights
Question: - rights
Name: - rights
Type: Lookup Select Box
order: - 300
Lookup from table: Application [customProfile]
Lookup value field: profiles
Lookup label field(s): u_right
Include none: true
Reference qualifier: javascript:'u_profile=' + current.variables.profile
Variable attributes: ref_qual_elements=profile

 Is my assumation right?

Kailash Bhange
Kilo Sage
Kilo Sage

Hi  KoenHaemels,

Yes, Your assumption is right. But there are some changes as it's a 3 variable lookup.

for the second variable: - 

Lookup value field --> should be the Profiles

 for the third variable: - 

Lookup value field: rights
Reference qualifier: javascript:'u_profiles=' + current.variables.profiles
Variable attributes: ref_qual_elements=profiles

 

Sachin mishra
Tera Explorer

Hi @Kailash Bhange

I have one table with 3 columns. Second column is dependent on first and 3 is on second. As per your recommendation, I have achieved required scenario for 2 look up select box but for 3 look up select box.. Logic is getting failed. 

Please suggest

Kailash Bhange
Kilo Sage
Kilo Sage

@Sachin mishra 
Have you updated, the variables as per my above configuration for 3rd variable

Sachin mishra
Tera Explorer

@Kailash Bhange 

Yes for the third variable i did but it is not showing any record. so in table 3 columns i have . from first column , there mulitple records present in second column and for each records , unique records are available in 3rd column.

Kailash Bhange
Kilo Sage
Kilo Sage

Please check my DM to more talk on the issue

Indira Panneers
Tera Contributor

Hi @Kailash Bhange 

Same problem for me also, I am using the same table sys_choice to store values

1)category

2)subcategory

3)impact category

 

subcategory depend on category working well

the impact category should depend on the subcategory and it is not working.

 

Your help is much required, if there is a solution to this.

flsn2
Tera Expert

is there a way to show value depending of the user language ?

suvi1
Tera Contributor

Hi.. Kailash Bhange

 

suvi1_0-1725533519708.png

 

 

Your solution is working for 2 variables from the above.

 

1. Source system

2. Entity   , are working   and i  am trying to populate 3.Data Owner  based on the 2. Entity.

 

Below is the screen shot.

suvi1_1-1725533710268.png

 

 

 

suvi1_2-1725533737344.png

 

 

 

 But this is not working for me.

Version history
Last update:
‎06-11-2020 11:37 PM
Updated by: