The CreatorCon Call for Content is officially open! Get started here.

Fetch a value from dropdown select box in workflow

Hemamani Prabha
Tera Contributor

Hello all,

 

I have a requirement in which I need to fetch the value of a selected option of a dropdown field from a table and set it in a variable and show in the task description. I need to do this scripting part in the workflow. Can someone help me how to achieve this ? This is how I tried, but not working

 

var comp = gr.u_computer.getOption('.u_computer', value).text;
var description = "Provide computer to" + gr.requested_for.getDisplayValue() + ":" comp "\n\n";

 

HemamaniPrabha_0-1694533707359.png

 

1 ACCEPTED SOLUTION

Siva Jyothi M
Mega Sage

Hi @Hemamani Prabha,

 

var ga  = new GlideRecord('computer_table);
ga.addQuery('add your query here')';
ga.Query();
if(ga.next()){
var comp = ga.u_computer.getDisplayValue(); // try with toString() as well
task.description = "Provide computer to" + gr.requested_for.getDisplayValue() + ":" comp "\n\n";
}

 

 

Mark this answer as correct and helpful if it solves your issue.

 

Regards,

Siva Jyothi M.

View solution in original post

3 REPLIES 3

Siva Jyothi M
Mega Sage

Hi @Hemamani Prabha,

 

var ga  = new GlideRecord('computer_table);
ga.addQuery('add your query here')';
ga.Query();
if(ga.next()){
var comp = ga.u_computer.getDisplayValue(); // try with toString() as well
task.description = "Provide computer to" + gr.requested_for.getDisplayValue() + ":" comp "\n\n";
}

 

 

Mark this answer as correct and helpful if it solves your issue.

 

Regards,

Siva Jyothi M.

Voona Rohila
Mega Patron
Mega Patron

Hi @Hemamani Prabha 
Try this,Chang the highlighted parts in the code:

 

var comp = gr.u_computer.getDisplayValue();
var description = "Provide computer to" + gr.requested_for.getDisplayValue() + ":" +comp +"\n\n";


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

We need to add + before and after comp to concatenate


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP