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.

Load Excel Data using GlideExcelParser

Gustavo Olivei1
Tera Contributor

Hello Community,

I am having an issue to import an Excel file using the attachment variable on the serviceportal.

Using Admin access I have no trouble to read the Excel data and fill a multirow variable set. But when I try it using a user with snc_internal (ordinary portal user) it is not possible. I guess this is related to ACL or other permission that I need to set, but I am having no progress to identify.

Then, here is the scenario:

Catalog Client script:

var ga = new GlideAjax('script_include_name');
ga.addParam('sysparm_name', 'getExcelData');
ga.addParam('sysparam_attSysId', att_sysid);
ga.getXML(callReturn);
}

function callReturn(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var excel = JSON.parse(answer);
//do a lot of things... and again with admin rights works fine
g_form.setValue('multirow_name', JSON.stringify(rowObj)); //rowObj is a variable that receive exceldata and set the MR

 

 

Script Include:

var CSCUtils = Class.create();
CSCUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getExcelData: function() {
var sysId_attachment = this.getParameter("sysparam_attSysId");
var parser = new sn_impex.GlideExcelParser();
var attachment = new GlideSysAttachment();
var attachmentStream = attachment.getContentStream(sysId_attachment);
parser.parse(attachmentStream);
var excelObj = [];
while (parser.next()) {
excelObj.push(parser.getRow());
}
return JSON.stringify(excelObj);
},

 

 

Someone can give a little help here ?

Note: I already tried the options: Client callable, Accessible from ... just in case

1 REPLY 1

Tudor
Tera Guru

Hi Gustavo,

If it works with an admin user and not with a snc_internal one it's definitely security.

You can try "Debug Security" and then impersonate the user and find the ACL which are restricting the access.

Hope this helps! 

Tudor