- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 11:23 PM
(function executeRule(current, previous) {
try {
gs.info("-------------------------111111111111111111");
var attachment = new GlideSysAttachment();
var attachmentContent;
gs.info("---------------------222222");
var agr = new GlideRecord('sys_attachment');
agr.addQuery('table_name','incident');
agr.addQuery('table_sys_id',current.sys_id);
agr.query();
gs.info("-----------------333");
while (agr.next()) {
gs.info('Attachment sys_id:' + agr.getValue('sys_id'));
gs.info('-------' + agr.getValue('file_name')); //print file name of attachment
attachmentContent = attachment.getContent(agr);
gs.info('------Attachment content: ' + attachmentContent); //print attachment content
}
}catch(e){gs.info('------------error in xml attachment '+e);}
})(current, previous);
Hi, i am having an issue with my business rule. in my business rule on sys_attachment table on condition filename is anything . when i add and save any attachment in the incident form ,i want to see the details of the attachment table sys id in system log
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 04:01 AM
You can use the below code to get attachment details in system log whenever any new attachment is attached to any table:-
var attachment = new GlideSysAttachment();
var agr = attachment.getAttachments(current.table_name, current.table_sys_id);
while (agr.next()) {
gs.info(agr.getValue('file_name')); //print file name of attachment
var attachmentContent = attachment.getContent(agr);
gs.info('Attachment content: ' + attachmentContent); //print attachment content
gs.info('Attachment content type' + agr.getValue('content_type'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 03:49 AM
cant use static sys id and also cant change target table ! Is there any other way to do this work ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 03:53 AM
can you intsruct me more to meet my requirements and what changes i have to do more to make my code perfect?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 04:01 AM
You can use the below code to get attachment details in system log whenever any new attachment is attached to any table:-
var attachment = new GlideSysAttachment();
var agr = attachment.getAttachments(current.table_name, current.table_sys_id);
while (agr.next()) {
gs.info(agr.getValue('file_name')); //print file name of attachment
var attachmentContent = attachment.getContent(agr);
gs.info('Attachment content: ' + attachmentContent); //print attachment content
gs.info('Attachment content type' + agr.getValue('content_type'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 04:12 AM
thankyou very much for finding the solution 😊
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2023 03:35 AM
yeah This is working but i need to get the content in attachment table not in incident table