Lookup select box with choices as lookup source not returning any choices

kareemyoune
Giga Contributor

I have a record producer, I liked it to a table u_maintenance_system.

I  have two fields, department and location. I have added choices to the sys_choice table, and made it that the location choices depend on the department choices.

So location_1, location_2 is dependent on department_A, and location_3 is dependent on department_B. And so on.

Back to the record producer, I was trying to add a variable of type lookup select box with the following type specifications
Lookup source: Choices
Choice Table: sys_choice
choice_field: Label
Choice depend on: Department
Include none: true

The result is an empty dropdown list with only the none value. even after selecting a department.
I have used the same choices in the table, and it works. When adding a new record from the form view, depending on the department selected, the relevant locations are shown.

I have tried to remove teh dependency from the record producer variable get the same issue.
So basically, the issue is getting any values what so ever back from the sys_chocie table via the lookup select box variable.

I also tried reference qualifiers, did not work as well.

The config

kareemyoune_0-1778677848682.jpeg

The record producer

kareemyoune_1-1778677885988.png

 

 




2 REPLIES 2

Ankur Bawiskar
Tera Patron

@kareemyoune 

this is how it should work, working outcome with incident category and subcategory

make 2nd variable dependent on 1st using variable attributes

ref_qual_elements=departmentVariableName

Category variable

55.png

Subcategory variable

56.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Mega Patron

HI @kareemyoune 

 

For your requirement , best choice would be 

 use Lookup Select Box variables combined with Reference Qualifiers to create the dependency.

 

 

Create/Configure Department Variable (Primary)

  • Type: Select Box or Lookup Select Box.
  • Name: department (Matches the field name on u_maintenance_system)
  • Choices: Ensure your choices exist in sys_choice for the u_maintenance_system table and department element.

 Create/Configure Location Variable (Dependent)

  • Type: Lookup Select Box.
  • Name: location (Matches the field name on u_maintenance_system)
  • Lookup from table: Choice [sys_choice]
  • Lookup value field: Value
  • Lookup label field: Label

In the Reference qualifier field for the location variable, add the following script:

javascript:'name=u_maintenance_system^element=location^inactive=false^dependent_value=' + current.variables.department;

 

To ensures the location field refreshes when the department changes, add a variable attribute

In the Variable attributes field of the location variable, add:

ref_qual_elements=department
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: