0

var getRitmID= current.sys_id;
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(getRitmID);
set.load();
var getVariables = set.getFlatQuestions();

var defineArray = [];

var generateHeader = [];

for(var i=0;j<getVariables.size();j++){

var variableLabel = getVariables.get(j).getLabel();

generateHeader.push(variableLabel.toString());

var variableValue = getVariables.get(j).getDisplayValue();

defineArray.push(variableValue.toString());

}

var HeaderRow = generateHeader.toString();
var valRow = defineArray.toString();
var attach = new GlideSysAttachment();

var newdoc = HeaderRow + "\n" + valRow;

var ritmRec = new GlideRecord('sc_req_item');
ritmRec.get(ritmSysId);

attach.write(ritmRec, "variables.csv", "text/csv", newdoc);

Generate csv file with the catalog variables and attaching to record ServiceNow
admin Changed status to publish December 26, 2023