How to grab value of Lookup Select Box in Flow Designer

Michael H1
Tera Guru

Apologies if this is in the incorrect location.

 

I have followed the following thread on the best way to directly reference certain choice fields on tables so that you do not need to go through the hassle of recreating choice options:

https://www.servicenow.com/community/developer-articles/dependent-select-box-choice-variables-on-rec...

Scenario:
We have a Catalog Item which has a Catalog Item Lookup Select Box that references "Substate" (substatus) on the Hardware (alm_hardware) table. I want to narrow the list of available Substates based on the dependent value. The dependent field being "State" (install_status). I accomplish that with these settings on that Catalog Item Variable:

 

Lookup_Field.png

 

In Flow Designer, I would then like to automatically set the Substate (substatus) of a Hardware record to the selected "Substatus" from this Lookup Select Box variable. I am unable to do so, however. After using the "Get Catalog Variables" action to grab the variable, if I drag that variable pill into the Substate value area, it only provides me a list of options to select from. I do not want this because it defeats the purpose of efficiently referencing the previous Substatus values I wanted to grab.

 

Flow_Designer.png

 

Does anyone know a way around this? Is the previously linked thread not the direction I should be taking? For more information, I do NOT have State as a Catalog Item Variable on the Catalog Item, the reason being anyone utilizing that Catalog Item is aware the intention of the Catalog Item is to change the Substate of the referenced Hardware record.

 

I would like the be able to show the list of Substates based on that specific State value then update the hardware record's Substate according the the selected value but Flow Designer appears to be limited based on the linked method. I am assuming because I'm not directly referencing Substate off of the Hardware table but instead using the sys_lookup table and narrowing the results there the actual Substate value is not able to be utilized to update the Hardware record's Substate.

1 ACCEPTED SOLUTION

Edxavier Robert
Mega Sage

Hi, 

After the step Get Catalog Variables form, can you create a new Lookup Records action and query the values that are you looking for? You will query the sys_choice table and use your reference qualifier to narrow down to what you need. 

View solution in original post

8 REPLIES 8

Tai Vu
Kilo Patron
Kilo Patron

Hi @Michael H1 

If I grasp it correctly, your form will have 3 variables: Hardware, State and Substate. Then when we select State, the Substate will only show choices based on the State.

Like below

Timi_0-1705982574900.png

 

From your lookup select box variable form, you should change the lookup value/label fields and the reference qualifier.

Timi_1-1705982674079.png

javascript: "name=alm_asset^element=substatus^language=en^inactive=False^dependent_value=" + current.variables.state

 

Cheers,

Tai Vu

Hi @Michael H1 

In your flow designer, you will need 2 steps.

1. Get the Catalog Variables

2. Update Record

Timi_2-1705982896292.png

Timi_3-1705982942038.png

 

Cheers,

Tai Vu

Hi Timi,

 

Close, only the State field is not accessible as a variable on the Catalog Item. Instead, it would be as if we know it is already set to the "Missing" state because the Catalog Item is specifically for reporting machines in a specific substate based on an already known State.

 

In Flow Designer I can see the value using the "Get Catalog Item Variables" action.

Substate_Value.png

 

But if I try to drag that data pill into the Substate field for the hardware record, it does not populate that value.

 

Substate_Value_2.png

 

I probably don't need to be so vague. Basically, this form is assumed to be used for Blocking machines in our environment and some automation is tied to it. At the end of the automation being completed, the hardware status of the referenced hardware record is marked as "Blocked" and Substatus needs to be updated to the Blocking Reason, such as missing, stolen, etc., but I do not appear to be able to grab the value from the sys_lookup table records for these Substatuses. The State IS updated to "Blocked" before the Substatus is attempted to be updated, ensuring the dependent value is marked appropriately ahead of time.

 

Here is a gif of what it looks like if I drag and drop the value into the Substate. After activating the flow, the Substate is never actually populated even though I can see the value in the "Get Catalog Item Variables" step.

Data_Pill_Population.gif

Hi @Michael H1 

If the State is already known in your scenario, why don't we just hard the State to a specific value (here is Blocked). After doing so, you should be able to drag the variable to the Substate field, as shown below.

Screenshot 2024-01-23 at 23.29.51.png

 

You can also attempt to add both the State and Substate and then remove the State afterward. However, please note that this may lead to potential bugs in the future due to inconsistency between the State and Substate.

Timi_1-1706027644000.png

 

Additionally, it has come to my attention that there might be an issue with your variable configuration. Setting the Lookup value field as Label could result in the Substate being left blank if the chosen option has a discrepancy between the Label and Value.

Timi_0-1706027207931.png

The Lookup value field should be Value and the Lookup label field should be label.

 

 

Cheers,

Tai Vu