How to Populate the select box label name which is selected in the service request using workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 06:51 AM
So in the short description of the RITM i am trying to populate the values which have been selected but unable to populate as shown in attached screenshot.
Used the below script to populate the value but was not bale to populate the Short Description.
// Ensure that current and current.cat_item are defined before proceeding
if (current && current.cat_item) {
var add = current.u_add;
var modify = current.u_mod;
var remove = current.u_rem;
var dele = current.u_del;
var selectedVariable = [];
if (add === true) {
selectedVariable.push('u_add');
}
if (modify === true) {
selectedVariable.push('u_mod');
}
if (remove === true) {
selectedVariable.push('u_rem');
}
if (dele === true) {
selectedVariable.push('u_del');
}
// Concatenate the selected variables and update short_description
current.short_description = current.cat_item.name + " + update: " + selectedVariable.join(', ');
} else {
// Handle the case when current or current.cat_item is undefined
current.short_description = "Error: cat_item or current is undefined.";
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 07:33 AM
If you're going to be doing strict equality comparisons (===) you need to verify the types are matching. I assume from this script that those variables aren't typeof boolean, they are strings. Change each if statement to validate against a string 'true'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 07:46 AM
Thanks for replying back, so I checked by replicating the same thing as you instructed, but it didn't work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 07:48 AM
Can you provide what code you attempted to run? Can you also try changing your comparisons to ==?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 07:51 AM
// Ensure that current and current.cat_item are defined before proceeding
if (current && current.cat_item) {
var add = current.u_add;
var modify = current.u_mod;
var remove = current.u_rem;
var dele = current.u_del;
var selectedVariable = [];
if (add == 'true') {
selectedVariable.push('u_add');
}
if (modify == 'true') {
selectedVariable.push('u_mod');
}
if (remove == 'true') {
selectedVariable.push('u_rem');
}
if (dele == 'true') {
selectedVariable.push('u_del');
}
// Concatenate the selected variables and update short_description
current.short_description = current.cat_item.name + " + update: " + selectedVariable.join(', ');
} else {
// Handle the case when current or current.cat_item is undefined
current.short_description = "Error: cat_item or current is undefined.";
}
Here is the code