RITM variable data into Custom CSV file format

Royal1
Tera Contributor

I wat to save the data into a particular formate 

 

i want to get the data and update in the file where ever i want 

 

code i have :

    var ritmSysId = current.sys_id;
    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 = Headers.toString().split(",");
    var valueRow = valuesArray.toString().split(",");
 
    var sa = new GlideSysAttachment();
 
var document = csvHeaderRow + "\n" + valueRow;
    var ritmRec = new GlideRecord('sc_req_item');
    ritmRec.get(ritmSysId);
 
    sa.write(ritmRec, "catalog_variables_details.csv", "text/csv", document);

 

1 ACCEPTED SOLUTION

@Royal 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Royal 

It seems you are referring my blog. I hope you have marked my blog as helpful and also bookmarked it

Generate csv file with the catalog variables and attaching to RITM record

Can you share what's not working?

Regards
Ankur

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

i tried and now its working and that for the help, 

yes i have followed your previous  blog

@Royal 

Glad to know.

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

@Royal 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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