We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Suppress False Values when Case is Submitted

jewing
Tera Contributor

Hello,

 

I have a record producer who has multiple checkbox variables. Agents asked to have the unchecked variables (FALSE) not render into the case and only keep those that are TRUE. I have this script (below), but I'm learning that the natural behavior is for ServiceNow to produce the FALSE value no matter what you do and this can't be overridden. Is this true, or is there a way around it?

Code:

var selectedLabels = [];
var vars = producer.variables;

 

for (var v in vars) {
    var variable = vars[v];
    var question = variable.getQuestion();

 

    if (!question) continue;

 

    if (question.getType() == 7 && variable == true) {
        selectedLabels.push(question.getLabel());
    }
}

 

// Append instead of overwrite (safer)
if (selectedLabels.length > 0) {
    current.description += "\n\nSelected Options:\n" + selectedLabels.join('\n');
}

 

new sn_hr_core.hr_ServicesUtil(current, gs)
    .createCaseFromProducer(producer, cat_item.sys_id);
4 REPLIES 4

Luca Michalczyk
Tera Contributor

I do not fully understand what you are trying to achieve.

If you are trying to achieve, that only checked Checkboxes are displayed in the description of the HRCase, you should already be on the right path. 

 

Try logging the value, using the outcome of the logging to make your if-statement more precise and then only append the variable + value if wanted.

Agents asked to have the unchecked variables (FALSE) not render into the case and only keep those that are TRUE. Meaning, they only want to see in the case submission items that are TRUE and not those that are FALSE. I managed to suppress everything totally, but can't find the correct syntax that would produce the desired result. 

Ankur Bawiskar
Tera Patron

@jewing 

on which UI they don't want to see the unchecked variables? Workspace or Portal etc?

share some screenshots

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hello,

 

Thanks for your reply. Yes, the customer wishes to see unchecked variables in the agent workspace /backend case details pane. I was able to suppress all items in the detail pane, but can't seem to only suppress all items that are the rendered as false.  Screenshots attached.