Get Lookup Select Box value in Flow Designer

ray evans
Tera Guru

Hi

 

UPDATE - I have retrieved the value using 

/var lab = fd_data.trigger.request_item.variables.allocate_asset_tag_serial_number.getDisplayValue();
return lab;
 
However, this returns the display name because that's what the variable displays - can I retrieve the asset tag in Flow designer as preference is to have the variable showing display name

 

 

 

Asset select box:

rayevans_0-1682279662424.png

Model Category

rayevans_1-1682279702042.png

 

11 REPLIES 11

Karan Chhabra6
Mega Sage
Mega Sage

Hi @ray evans ,

 

You can toggle the inline script for the model category variable in the update record action and paste the following lines of code, replace 'model_category' with you catalog item variable name.

vat modelCategory = fd_data.trigger.request_item.variables.model_category.getValue();
return modelCategory;

KaranChhabra6_0-1682282489809.png

 

If my answer has helped with your question, do mark this solution as helpful and accepted solution.

 

Thanks,
Karan

 

AnveshKumar M
Tera Sage
Tera Sage

Hi @ray evans ,

 

You can try these two approaches.

 

1. Using the sys_id:

In your variable configuration set Look Up Value field to sys_id and LookUp label field to the Display name (give the field name instead of field label). This way when you retrieve the variable in Flow it gives you sys_id which you can use to Glide the alm_asset table and retrieve any data related to that record, like asset tag in your case.

 

2. Asset tag as Lookup Value Field:

In this approach if you don't want any other data related to that asset record, you just want asset tag, configured the variable Lookup value field to asset_tag and Label field to display name (give the field name instead of field label).

 

This way you cab directly get the asset tage in the flow designer.

 

 

Thanks,
Anvesh

@AnveshKumar M Thanks - Approach 1 looks like what I'm after. Can you point me in the right direction as to how to retrieve the value in script? I have tried the following but I know it isn't right.

 

*/var lab = fd_data.trigger.request_item.variables.allocate_asset_tag_serial_number.getValue();
var gr = new GlideRecord('alm_asset');
gr.addQuery('sys_id', lab);
gr.query();
var asset_tag = gr.getValue('asset_tag');
return asset_tag;

Hi @ray evans 

Try using this code.

 

var lab = fd_data.trigger.request_item.variables.allocate_asset_tag_serial_number;
var gr = new GlideRecord('alm_asset');
gr.addQuery('sys_id', lab);
gr.query();
var asset_tag;
if(gr.next()){
asset_tag = gr.getValue('asset_tag');
}
return asset_tag;
 
 
Thanks,
Anvesh