
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 12:19 PM
Getting this error when I run the following script in New York P1/HF1:
var attachmentIS = new GlideSysAttachmentInputStream('SYS_ID_OF_ANY_ATTACHMENT');
var bytearrayOS = new Packages.java.io.ByteArrayOutputStream();
attachmentIS.writeTo(bytearrayOS);
Error:
Attempted script access to inaccessible member denied - com.glide.ui.SysAttachmentInputStream:writeTo:(Ljava/io/OutputStream;)V
Evaluator: java.lang.SecurityException: Illegal access to method writeTo(java.io.ByteArrayOutputStream) in class com.glide.ui.SysAttachmentInputStream
Caused by error in script at line 3
1: var attachmentIS = new GlideSysAttachmentInputStream('f7ecf6dd1b208c50791aea866e4bcb19');
2: var bytearrayOS = new Packages.java.io.ByteArrayOutputStream();
==> 3: attachmentIS.writeTo(bytearrayOS);
Background message, type:error, message: Illegal access to method writeTo(java.io.ByteArrayOutputStream) in class com.glide.ui.SysAttachmentInputStream
Anybody seen this? I don't see any replacements for Packages.java.io.ByteArrayOutputStream if that's the issue.
Edit: Global scope.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2019 03:27 AM
Hi
I found the solution for your problem. Looks like ServiceNow has changed a little bit. OOTB example in sys_script.do?sys_id=468eebfeff447300c2e8a897d53bf16e.
sa = new GlideSysAttachmentInputStream(saGr.sys_id);
content = new Packages.java.io.ByteArrayOutputStream();
sa.writeTo(content, 0, 0);
content.close();
You have to use attachmentIS.writeTo(bytearrayOS, 0, 0);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2019 02:56 PM
Hi Sebastianreinmann,
I have the similar issue of sending >5MB attachments to the thrid party system through SOAP web service integration. I have tried the above code you mentioned, it was working fine and I was able to successfully send the attachments of 5.3 MB or 5.4MB but I could'nt send >7MB. Is there any size limitations on using Packages.java.io.ByteArrayOutputStream(). Currently I am on NY patch 2.
Any recommendations would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 01:05 PM
Hello All,
I've made the change "attachmentIS.writeTo(bytearrayOS, 0, 0);" to my script include, the error does not happen but the attached file does not go when the case is save and the BR run. Is there anything I should look for?
Thanks,