It’s possible to do this with a more practical piece of code, without having to query several tables to get the CSV output of the variable fields in the RITM.
Thanks to the following FIX script code, you can get the CSV output of the variables and have it added as an attachment to the record.
// var ritmSysId = current.sys_id;
var ritmSysId = 'c5cc43b22f143010731b2f2ef699b6e5';
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);
set.load();
var vs = set.getFlatQuestions();
var valuesArray = [];
var csvHeader = [];
for(var i=0;i<vs.size();i++){
var variableLabel = vs.get(i).getLabel();
csvHeader.push(variableLabel.toString());
var variableValue = vs.get(i).getDisplayValue();
valuesArray.push(variableValue.toString());
}
var csvHeaderRow = csvHeader.toString();
var valueRow = valuesArray.toString();
var sa = new GlideSysAttachment();
var document = csvHeaderRow + "n" + valueRow;
var ritmRec = new GlideRecord('sc_req_item');
ritmRec.get(ritmSysId);
sa.write(ritmRec, "catalog_variables.csv", "text/csv", document);

Share your experience
Bir sorunun, farklı bir çözümün veya eklemek istediğin bir notun var mı? Giriş yapmadan da yazabilirsin.