How to Populate the select box label name which is selected in the service request using workflow

Community Alums
Not applicable

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.

PRITHVIRAMESH_0-1690552233562.png

 

// 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.";
}
9 REPLIES 9

Community Alums
Not applicable

And one more thing that i have used checkbox as a variable.

Are u_add, u_mod, etc variables? If so, you have to access them via current.variables.u_add, current.variables.u_mod, etc. 

Community Alums
Not applicable
// Ensure that current and current.cat_item are defined before proceeding
if (current && current.cat_item) {
    var add = current.variables.u_add;
    var modify = current.variables.u_mod;
    var remove = current.variables.u_rem;
    var dele = current.variables.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.";
}

 

I replicated the same as instructed but still same issue is occurring.

Can you attempt to add some log statements and verify those variables are pulling back values? 

 

Also try this:

// Ensure that current and current.cat_item are defined before proceeding
if (current && current.cat_item) {
    var add = current.variables.u_add;
    var modify = current.variables.u_mod;
    var remove = current.variables.u_rem;
    var dele = current.variables.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.";
}
 

 

Community Alums
Not applicable
// Ensure that current and current.cat_item are defined before proceeding
if (current && current.cat_item) {
    var add = current.variables.u_add;
    var modify = current.variables.u_mod;
    var remove = current.variables.u_rem;
    var dele = current.variables.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.";
}

 

Now in the output only "Cat Item Name + update: " this much is visible and the value which is selected is not populating