How can I copy/send attachment using scheduled job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 10:49 AM - edited 01-09-2023 12:08 PM
Hi,
How can I send attachment to the task using scheduled job. I am using below script it is successfully creating task but file is not getting attached.
var ptask = new GlideRecord('u_property_it_tasks');
ptask.get('d04fe0e51b9ce5187ccda687bd4bcbb7');
ptask.initialize();
new GlideSysAttachment().copy("u_property_it_tasks", ptask.getUniqueValue(), "u_property_it_tasks", ptask.sys_id);
ptask.short_description = 'Weekly Check Sun/Mon ';
ptask.description = 'Perform maintenance please refer to the attached document.';
ptask.assignment_group = '92821b43db6db6401c7c5dd5ce9619ca';
ptask.insert();
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 05:43 PM
Try below
var ptask = new GlideRecord('u_property_it_tasks');
ptask.get('d04fe0e51b9ce5187ccda687bd4bcbb7');
var ptasknew = new GlideRecord('u_property_it_tasks');
ptasknew.initialize();
ptasknew.short_description = 'Weekly Check Sun/Mon ';
ptasknew.description = 'Perform maintenance please refer to the attached document.';
ptasknew.assignment_group = '92821b43db6db6401c7c5dd5ce9619ca';
ptasknew.insert();
new GlideSysAttachment().copy("u_property_it_tasks", ptask, "u_property_it_tasks", ptasknew.sys_id);