- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2020 11:41 PM
Hi Team,
I want to know the alternative method for using the below java package in business rule. I have used this package to fetch data from an attachment for live chat requirement.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2020 01:22 AM
Hi,
So basically you want to get the content of the file.
For scoped application you can use this
var attachment = new GlideSysAttachment();
var incidentSysID = '0e352ec80745ac54540bf2508c1ed0b7';
var agr = attachment.getAttachments('sc_cart_item', incidentSysID);
if (agr.next()) {
var attachmentContent = attachment.getContent(agr);
gs.info('Attachment content: ' + attachmentContent);
}
For global application you can use this
var sysIdOfRecord = '0e352ec80745ac54540bf2508c1ed0b7';
var grAttachment = new GlideRecord('sys_attachment');
grAttachment.get('table_sys_id', sysIdOfRecord);
var ga = new GlideSysAttachment();
var base64EncodedData = GlideBase64.encode(ga.getBytes(grAttachment));
var data = GlideStringUtil.base64Decode(base64EncodedData);
gs.print("Information Available in File: " + data);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2020 11:51 PM
package call won't work in scoped applications
what is your requirement?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2020 01:07 AM
Hi Ankur, We have to fetch the data from interaction attachment to variable 'tr' in the business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2020 01:22 AM
Hi,
So basically you want to get the content of the file.
For scoped application you can use this
var attachment = new GlideSysAttachment();
var incidentSysID = '0e352ec80745ac54540bf2508c1ed0b7';
var agr = attachment.getAttachments('sc_cart_item', incidentSysID);
if (agr.next()) {
var attachmentContent = attachment.getContent(agr);
gs.info('Attachment content: ' + attachmentContent);
}
For global application you can use this
var sysIdOfRecord = '0e352ec80745ac54540bf2508c1ed0b7';
var grAttachment = new GlideRecord('sys_attachment');
grAttachment.get('table_sys_id', sysIdOfRecord);
var ga = new GlideSysAttachment();
var base64EncodedData = GlideBase64.encode(ga.getBytes(grAttachment));
var data = GlideStringUtil.base64Decode(base64EncodedData);
gs.print("Information Available in File: " + data);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2020 05:15 AM
Hi Ankur, This worked for me. Thanks a lot.