Import CSV file data from MID Server using remote file importer

Narsi
Tera Expert

Hi,

I have uploaded the "Remote File Importer" update set.

https://developer.servicenow.com/connect.do#!/share/contents/2271821_remote_file_importer_import_fil...

Mid Server Path: E:\admin\Servicenow\agent\  it is a network location  

File Path to import E:\admin\Servicenow\agent\import\test.csv

I can not see anything that happened when executed, I mean not importing anything.

Any ideas to work out this

find_real_file.png

 

 

Thanks,

Narsi

1 ACCEPTED SOLUTION

Hi,

seems some issue with java package call

Regards
Ankur

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

View solution in original post

13 REPLIES 13

Hi,

you need to debug line by line. check the function which is getting called and debug that

Regards
Ankur

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

Hi @Ankur Bawiskar 

Thank you for replying 

I have checked 

I got a response from the log file as below, I put the mid server password instead of this.probeParameters.instancePassword and user name instead of this.probeParameters.instanceUser like 

 var userpass = new java.lang.String(t"MidServerUserName:MidServerPassword");

but no luck. any ideas?

 

08/20/20 12:35:53 (653) Worker-Standard:JavascriptProbe-6fe138f8dbbedc9444ce97f2f39619b6 WARNING *** WARNING *** org.mozilla.javascript.EcmaError: "java" is not defined.
Caused by error in MID Server script include 'CSMIDServerRemoteFileImport' at line 59

56: }
57: var conn = new Packages.java.net.URL(url).openConnection();
58: this.logMsg("Sending to : " + url, "debug");
==> 59: var userpass = new java.lang.String(this.probeParameters.instanceUser + ":" + this.probeParameters.instancePassword);
60: var basicAuth = "Basic " + (new Packages.javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes()) + '');
61: conn.setRequestProperty("Authorization", basicAuth);
62: conn.setDoOutput(true);

08/20/20 12:35:53 (653) Worker-Standard:JavascriptProbe-6fe138f8dbbedc9444ce97f2f39619b6 WARNING *** WARNING *** org.mozilla.javascript.EcmaError: "java" is not defined.
Caused by error in MID Server script include 'CSMIDServerRemoteFileImport' at line 18

15: },
16: getRemoteFileAndUploadToInstance: function() {
17: var url = this._getInstanceConnectionURL();
==> 18: var conn = this._getURLConnection(url);
19: var file = this._getFile();
20: var response = this._writeFile(conn, file);
21: if (response != 200)

08/20/20 12:35:53 (653) Worker-Standard:JavascriptProbe-6fe138f8dbbedc9444ce97f2f39619b6 WARNING *** WARNING *** org.mozilla.javascript.EcmaError: "java" is not defined.
Caused by error in JavaScript probe 'CSRemoteFileImport' at line 2

1: var remoteFileImport = new CSMIDServerRemoteFileImport();
==> 2: remoteFileImport.getRemoteFileAndUploadToInstance();

08/20/20 12:35:53 (653) Worker-Standard:JavascriptProbe-6fe138f8dbbedc9

 

Thanks,

Narsi.

Hi,

seems some issue with java package call

Regards
Ankur

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

Hi

I have changed that to 

Packages.java.lang.String(this.probeParameters.instanceUser + ":" + this.probeParameters.instancePassword);

then it works.

and I got another error:

 var data = new Packages.java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 4096);

I have change it to 

 var data = Packages.java.lang.reflect.Array.newInstance(Packages.java.lang.Byte.TYPE, 4096);

 

It works now, I'm able to import from Mid Server

@Narsi 

Great!  It looks like you marked your own response as the correct answer, which may be confusing to others that read this later.

I felt I covered that above pretty well (first) regarding the java package call.

Would you mind marking my response as helpful/correct if I am able to resolve your query?

Regards
Ankur

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