Converting attachment to base64 in form or workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 09:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 10:24 AM
This article might help:
https://community.servicenow.com/community?id=community_question&sys_id=de244af1db27f3444819fb243996...
And this one:
https://community.servicenow.com/community?id=community_question&sys_id=bedef2e5db58dbc01dcaf3231f96...
There are ways to encode and decode base64 with a script, so you could do this in a workflow activity or a business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 11:16 AM
HI Timmo,
i written below script
var attachment = new GlideSysAttachment();
var agr = attachment.getAttachments('ZZ_YYsc_cart_item', '816e5064c311111037a02e5ce0013114');
if (agr.next()) {
gs.info(agr.getValue('file_name'));
var attachmentContent = attachment.getContentBase64(agr);
gs.info('Attachment content base64 encoded: ' + attachmentContent);
}
in log i am getting the file name correct but base64 format getting undefined
*** Script: Bulk.xlsx
*** Script: Attachment content base64 encoded: undefined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 10:26 AM
Hi,
You can refer to the GlideSysAttachment API, for example: https://developer.servicenow.com/dev.do#!/reference/api/rome/server/no-namespace/c_GlideSysAttachmen...
As far as when to do this, you can do it in business rule or workflow, anywhere you have access to server side script that's relevant to this process. That's something you'll want to decide as far as how and when to do it. Workflow would be more relevant...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!