Daisy chained reference fields

erin-marie
Tera Contributor

I am trying to do a daisy chain of lookups.  The variable 1 and variable 2 lookups are working fine.  The problem is I am using the field “label” in variable 2 and 3, but I want to take what is returned in variable 2 and use it to look up a match in variable 3 “parent_id” field. 

 

If the user selects label in variable 2 is abc.

Then variable 3 should show selections where label has a parent id of abc

 

Does that make sense?  Is this doable?

 

Variable 1

 

Variable question: Knowledge Base

Variable Name: sc_kb_itsm_knowledge_base

Type: Lookup Select Box

Table: kb_category

Lookup value field: Parent ID (parent_id)

Reference qualifier: parent_id=92e52b3287e9ea1008b30f270cbb35fb^ORparent_id=4495633287e9ea1008b30f270cbb35b5

 

Variable 2

 

Variable question: Category

Variable Name: sc_kb_itsm_category

Type: Lookup Select Box

Table: kb_category

Lookup value field: Label (label)

Reference qualifier: javascript: 'parent_id=' + current.variables.sc_kb_itsm_knowledge_base

Variable attributes: ref_qual_elements=sc_kb_itsm_knowledge_base

 

Variable 3

 

Variable question: Internal Subcategory

Variable Name: sc_kb_itsm_int_subcategory

Type: Lookup Select Box

Table: kb_category

Lookup value field: Label (label)

Reference qualifier: javascript: 'parent_id=' + current.variables.sc_kb_itsm_category

Variable attributes: ref_qual_elements=sc_kb_itsm_category

 

2 REPLIES 2

Itallo Brandão
Mega Guru

Hi Erin-Marie,

 

Yes, this makes perfect sense and is a very common scenario!

 

The issue lies in the Lookup value field configuration for Variable 2.

 

The Technical Mismatch:

  • Variable 3 tries to filter its list using parent_id=VALUE_OF_VAR_2.

  • The field parent_id on the kb_category table is a Reference field, meaning it expects a Sys ID (the 32-character unique identifier).

  • However, your Variable 2 is currently configured to pass the Label (text name, e.g., "Hardware") as its value.

  • So, the system tries to query parent_id=Hardware, finds no match, and returns an empty list for Variable 3.

The Fix: You need to pass the Sys ID to the next variable while still showing the Label to the user.

  1. Open Variable 2 (sc_kb_itsm_category).

  2. Change the Lookup value field from label to sys_id.

    • Note: The users will still see the "Label" in the dropdown list (because Select Boxes display the table's "Display Value" by default), but the underlying value stored and passed to Variable 3 will now be the correct Sys ID.

  3. (Optional) Do the same for Variable 3 if you plan to have a Variable 4 or if you want to use the value in scripts later. Storing Sys IDs is generally best practice for reference data.

Once you make that change, your reference qualifier javascript: 'parent_id=' + current.variables.sc_kb_itsm_category will work perfectly because it will translate to parent_id=[SYS_ID_OF_PARENT].

 

Hope this gets your chain working!

 

If this response helps you achieve your requirement, please mark it as Accepted Solution.

This helps the community grow and assists others in finding valid answers faster.

 

Best regards,

Brandão.

TejasSN_LogicX
Tera Contributor

 

Hi @erin-marie ,

ariable 2 (sc_kb_itsm_category) is returning Label, but parent_id is a sys_id in the table kb_category.When chaining lookups, always use sys_id as the value of the variable that will be used in a reference qualifier for parent_id.