- 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-14-2020 05:43 AM
Glad to help.
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
‎04-05-2022 12:31 AM
Hi Ankur,
How can we loop through each line from the variable?
In this case 'data' variable having data, can we go through line by line?
If we can loop through then I wanted to add each line value to an array and the array will be used in next step of flow to update a record.
Thanks