Read the content of an Excel File and upload it into ServiceNow tables

arunmayakrishna
Kilo Contributor

Hi,

I am trying to develop a piece of code in ServiceNow which automatically uploads the data of the Excel file into ServiceNow existing tables, through Bisiness Rule. But I am facing some issues with the package constructor. Please find below the script I used for getting the content of the file. It would be really appreciable, if someone has performed this activity and could share their views and code snippet which might be very helpful for me. I have gone through multiple discussion in community and tried all the solution, but no luck nothing worked for me to get rid of this error.

Instance Platform: Istanbul

Script:

StringUtil = GlideStringUtil;

sa = new GlideSysAttachment();

gs.addInfoMessage('Found Attachment.');

var bytesContent = sa.getBytes('sc_req_item', current.sys_id);

tempdata = String(Packages.java.lang.String(bytesContent));

strData = tempdata.replaceAll("&", "&");

Error:

"The choice of Java constructor java.lang.String matching JavaScript argument types (null) is ambiguous; candidate constructors are: String(java.lang.StringBuilder) String(java.lang.StringBuffer) String(byte[]) String(char[]) String(java.lang.String) (sys_script.90106950db233200605d712ebf9619fe.script;"

Thanks,

Arun

10 REPLIES 10

mitzaka
Mega Guru

Why don't you use the data import option, having this excel as a data source?


Import a translation from an Excel spreadsheet


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Arun,



Why are you doing in this manner.


Why not use Data source to load data in target table?



Regards


Ankur


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

dj21
Giga Expert

There are many share solutions available to import an excel into SNOW table.One sample below


https://share.servicenow.com/app.do#/detailV2/385c2ca713767a000de935528144b0db/overview


As others suggested, try using the data source and transform maps for validating excel entries.