0

var gr = new GlideRecord("sc_req_item");
if (gr.get("d5ba793987e39e1093e30d490cbb35f9")) {
    var getRole = '';
    var variables = gr.variables.getElements();
    var question,
        value;
       for (var i = 0; i < variables.length; i++) {
            var question = variables[i].getQuestion();
        var label = question.getLabel();
        var value = question.getDisplayValue();
         if (value == "true") {
            getRole += label + "\n";
        }
    }
    gs.print(getRole);
}

Script to only display Variables with an answer from a Record Producer
Working Code Asked question April 28, 2025