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);
0 REPLIES 0