- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 03:49 AM
Hi team ,
we wrote a BR to capture the attachment and convert o base 64,But i am facing issue to capture the multiple attachment for current incident
var tarRec = new GlideRecord(current.table_name);
var sa = new GlideSysAttachment();
var binData = sa.getBytes(current);
var base64Data = GlideStringUtil.base64Encode(binData);
var Attachment = new sn_ws.RESTMessageV2('ABC', 'XYZ');
Attachment.setStringParameterNoEscape('att_data', base64Data);
Attachment.setStringParameterNoEscape('att_type', current.content_type);
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 08:06 AM
did you use variable substitution for setting the attachment data?
you should create variable substitution something like this and then set the data
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
09-18-2020 06:49 AM
i am following the above format ,so in the business rule i have to iterate the json body
can you please share the reference code it would be helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 07:48 AM
something like this
var arr = [];
var currentRecordSysId = current.sys_id;
var tarRec = new GlideRecord('sys_attachment');
tarRec.addQuery('table_sys_id', currentRecordSysId);
tarRec.query();
while(tarRec.next()){
var sa = new GlideSysAttachment();
var binData = sa.getBytes(tarRec);
var base64Data = GlideStringUtil.base64Encode(binData);
var obj = [];
obj["att_data"] = base64Data;
obj["att_type"] = tarRec.content_type.toString();
arr.push(obj);
}
// call rest message and then set the body as below
var Attachment = new sn_ws.RESTMessageV2('ABC', 'XYZ');
Attachment.setStringParameterNoEscape('attachmentData', JSON.stringify(arr));
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
09-18-2020 11:43 AM
using the below json and added the attachment but Attachment data not moving to JSON body in rest message .!
Attachment.serStringParameterNoEscape('Attachments',JSON.Stringify(arr));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2020 08:06 AM
did you use variable substitution for setting the attachment data?
you should create variable substitution something like this and then set the data
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader