how to copy attachment to HR case after submitting the employee form task from portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 05:03 AM
We are having attachment fields on employee form and hr case as well and both fields mapped to each other. so when ever uploading file to employee form task from portal , the attachment file should be copy to parent hr case after submitting the employee form task from portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 07:50 PM
you can have after insert BR on sys_attachment table and condition as Table is Employee Task
Then copy that file
what script did you start with?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 01:38 AM
After submitting form from portal the attachment should be copy on hr task
(function executeRule(current, previous /*null when async*/) {
if(current.operation() == 'insert')
new GlideSysAttachment().copy('sys_attachment', current.sys_attachment, 'sn_hr_core_task', current.table_sys_id);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 03:18 AM
i am trying with below br after insert but attachment not coping from attachment to table to hr task table
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var copy = new GlideRecord('sn_hr_core_task');
copy.addQuery('parent', current.getUniqueValue());
copy.query();
if (copy.next()) {
GlideSysAttachment.copy('sys_attachment', current.getUniqueValue(), 'sn_hr_core_task', copy.getUniqueValue());
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2023 07:24 PM
Can you try the following code?