how to copy attachment to HR case after submitting the employee form task from portal

vijani
Tera Expert

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.

 

@Ankur Bawiskar 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@vijani 

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?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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);

vijani
Tera Expert

Hi @Ankur Bawiskar 

i am trying with below br after insert but attachment not coping from attachment to table to hr task table 

vijani_0-1684491457949.png

 

(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);

Can you try the following code?

JohnZhang1_0-1684549456619.png