Gliderecord query

CV1
Tera Contributor

Hello ,

looking for script to fetch value from a table based on another value.

 

Table A had fields Business unit and department no. Based on Business unit, need to fetch department no this is in a sub flow.

var bu = fd_data.subflow_inputs.businessunit;
if(bu == ""){
return "";
}
var gr = new GlideRecord('Table A');
gr.addQuery('business_unit_id',bu);
gr.query();
if(gr.next()){
return gr;
 }
 
 
 
   TIA
3 REPLIES 3

siva krishna M2
Tera Guru

Hello @CV1 ,

 

Try below script in script action for the field department :

 

var bu = fd_data.subflow_inputs.businessunit;
if(bu == ""){
return "";
}
var gr = new GlideRecord('Table A');
gr.addQuery('business_unit_id',bu);
gr.query();
if(gr.next()){
return gr.department;
//use field value of department
 }

Allen Andreas
Administrator
Administrator

Hello,

If the business unit is from the parent flow and an input to your subflow, then you don't really need to use script for this. You can use a lookup record action, select the table, then add the condition and drag the pill for the BU input into it and go from there. You'd be be able to use the looked up record and any dot-walking, as needed later in the flow. Unless your script is more complex than what you've shown here, the low-code/no-code option of what I mentioned would be preferred.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

this is a scripted rest api calling a subflow