Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mrvs issue with excel sheet.

keshav77
Tera Contributor

Hi All,

 

I am trying to achive to pull the data from excel data sheet to Mrvs. Which I am able to but now I want that   the excel should take the required data in mrvs from row 4 ownward and row 3 is work as header.  like below ss. where row 3 are headers and I am sharing my script script include where I am getting attcahemet. please let me know what changes I need to make in the script to achive this.

 

script include----

getdata: function() {

var id = this.getParameter('sysparm_id');
var obj = [];
var excelid = id;
var parser = new sn_impex.GlideExcelParser();
var attach = new GlideSysAttachment();

var attachmenttest = attach.getContentStream(excelid);
parser.parse(attachmenttest);
while (parser.next()) {
var row = parser.getRow();
obj.push(this.prepareData(row));
}


return JSON.stringify(obj);


},

keshav77_0-1750961084044.png

@Ankur Bawiskar can you help me with this

1 ACCEPTED SOLUTION

Hi,

The lines I have added will skip the first three line. Did you try the script?

Thank you,
Palani

View solution in original post

7 REPLIES 7

palanikumar
Giga Sage
Giga Sage

Hi,

You can make the highlighted modification:

 

getdata: function() {

var id = this.getParameter('sysparm_id');
var obj = [];
var excelid = id;
var parser = new sn_impex.GlideExcelParser();
var attach = new GlideSysAttachment();

var attachmenttest = attach.getContentStream(excelid);
parser.parse(attachmenttest);

var rowNum = 0;

while (parser.next()) {

rowNum = rowNum + 1;

if(rowNum >3){
  var row = parser.getRow();
  obj.push(this.prepareData(row));
}

}
return JSON.stringify(obj);
},

Thank you,
Palani

@palanikumar @Ankur Bawiskar  this will not work as I want header in 3 row then from the 4 row I will enter the data. the script given by you only work when header in 1st row . so how to make header in 3 row  as I shared excel sheet above

@keshav77 

please share complete script and screenshots as well.

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

Hi,

The lines I have added will skip the first three line. Did you try the script?

Thank you,
Palani