- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 08:53 AM
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";
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 09:16 AM - edited 09-12-2023 09:17 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 09:16 AM - edited 09-12-2023 09:17 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 09:38 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 09:41 AM
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