Unable to copy attachments using flow designer

Sriniwas
Mega Contributor

Hi,

I'm trying to copy attachments from one record to another using flow designer and unable to do it.

For example, I have attachment on problem record and have created problem task, now i want to copy the attachment from problem to problem task once task is created.

Below are the steps trying in flow designer.

Step1: trigger condition given as record created in problem task table.

find_real_file.png

 

Step 2: Searching for the problem table in sys_attachment table

find_real_file.png

Step 3: copying the attachment from step 2 lookup record to the problem task record in problem task table.

find_real_file.png

And it is not copying the attachments from problem to problem task.

Can any one please help me on this.

1 ACCEPTED SOLUTION

Frist lookup the attachments and then use copy attachement action.
The world works with ServiceNow

View solution in original post

6 REPLIES 6

Sagar Pagar
Tera Patron

Hello Sriniwas,

 

Better to create "Copy-attachment" action and use in main flow to copy the attachment from source to destination.

 

Create inputs variables,

find_real_file.png

used in Script step:

find_real_file.png

 

(function execute(inputs, outputs) {
// ... code ...
  
  var copyAttachment = new GlideSysAttachment();
  copyAttachment.copy(inputs.sourceTable, inputs.sourceId, inputs.targetTable, inputs.targetId );
                              
  
})(inputs, outputs);

and used in main flow, Changed as you need to copy attachment from Problem record to Problem task.

find_real_file.png

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Hi Sagar,

Thanks for the reply.

have created the new action as suggested.

Action Inputs:

find_real_file.png

 

Action Script:

find_real_file.png

Trigger Point: when the record created in problem task table

find_real_file.png

 

Calling Custom Action created at step 1:

find_real_file.png

Still unable to copy attachments from problem to problem task.

Not sure, where is the mistake in the steps.

 

Thanks,

Sriniwas

Frist lookup the attachments and then use copy attachement action.
The world works with ServiceNow

Thank you, it is working perfect.