ISSUE in SENDING ATTACHMENTS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2013 06:02 AM
Hi Guys,
I am trying to send the attachments through web services and i am using the following business rule
var StringUtil = Packages.com.glide.util.StringUtil;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.addQuery('table_name', current.getTableName());
var fil = gr.file_name;
var typ = gr.content_type;
gr.query();
if (gr.next()){
var sa = new Packages.com.glide.ui.SysAttachment();
var binData = sa.getBytes(gr);
var encData = StringUtil.base64Encode(binData);
gs.log(encData,'encoded');
}
else{
gs.log('record not found');
}
var s = new SOAPMessage('test_attach1', 'insert');
s.setParameter('name',fil+":"+typ);
s.setParameter('payload',encData);
s.setParameter('topic', 'AttachmentCreator');
s.setParameter('source', "incident:"+current.sys_id);
s.setParameter('agent', 'AttachmentCreator');
var response = s.post();
gs.log(response,'AT109');
But when the business rule is executed in the system logs the evaluator is throwing the following error:
java.lang.SecurityException: Illegal attempt to access class 'com.glide.ui.SysAttachment' via script
Caused by error in Business Rule: 'ATTACHMENT' at line 12
9: gr.query();
10:
11: if (gr.next()){
==> 12: var sa = new Packages.com.glide.ui.SysAttachment();
13: var binData = sa.getBytes(gr);
14: var encData = StringUtil.base64Encode(binData);
15: gs.log(encData,'encoded');
Why am I getting this error?Is there any ways to get the access to the 'com.glide.ui.SysAttachment' class?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2013 10:17 AM
I'm guessing you are on Calgary and hence any Package calls won't work, Do let me know if you aren't and you still are getting the error.
If you are on Calgary, replace
with
Packages.com.glide.ui.SysAttachment
and
GlideSysAttachment
with
Packages.com....StringUtil
GlideStringUtil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 05:25 AM
Thanks Abhiram, that works perfectly!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2017 06:22 AM
Thanks Abhiram !! Faced the same issue and it worked perfectly
Thanks
Gopinath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 04:30 AM
I am getting the same issue. Illegal attempt to access class 'com.glide' via script
i am using helsinki developer instance