Campaign Delivery- Attachment | Community
Skip to main content
Level 2
March 5, 2019
Solved

Campaign Delivery- Attachment

  • March 5, 2019
  • 19 replies
  • 14302 views

Hi,

I want to export the data in temp work table as csv file & need to attach the file automatically to the email delivery, its fine if i export or import the file to my local machine or from the server. Need some help on this

Regards,

Raaghu

Best answer by Jean-Serge_Biro

Hi Raaghu,

Please do what I mentioned above:

1. add a Delivery activity (NOT a continuous delivery), based on a Delivery Template (model) in which you select the To field as population coming from workflow.

2. In the wfk delivery activity, click on the 2nd tab (Script tab), then paste this:

delivery.attachment.add(
  <attachment compressMode="print" filterActive="false" label="my label"
              nameScriptActive="false" type="normal" upload="false">
    <name>{instance.vars.filename}</name>
  </attachment>)

delivery.hasAttachments = true

That's all

19 replies

Jonathon_wodnicki
Community Advisor
Community Advisor
March 6, 2019

Hi,

Use calculated file attachment:

The filename out of extract transition should be vars.filename, avoid hardcoding the path in the delivery to ease maintenance (use an xtk:option).

Thanks,

-Jon

RaaghuikAuthor
Level 2
March 6, 2019

Hello,

I was trying to use the data extraction activity in the workflow to export the data in the temp work table & to attach it to the email delivery.

1.Need to know how to export the data to server or to the local machine (Anythings fine)

2.How to attach the file automatically to the email delivery after export

3. Or is there any other way to achieve this task.

Jean-Serge_Biro
Level 10
March 6, 2019

Hi Raagu,

In addition of Jon's answer, and because it seems there is not anymore this tip in the documentation regarding attaching files in a delivery, one way of doing it through a workflow is to write this code in the 2nd tab of the delivery activity, from your workflow:

delivery.attachment.add(
  <attachment compressMode="print" filterActive="false" label="my label"
              nameScriptActive="false" type="normal" upload="false">
    <name>{instance.vars.yourvariable}</name>
  </attachment>)

delivery.hasAttachments = true

Of course, as Jon mentioned, you can use vars.filename variable.

But take care, in such case, the delivery activity must follow immediately the Extract activity, because other activities can override the variable filename value.

For instance, in some cases, you must attach several files, or compress (zip) the extracted file, or whatever. In such cases, save the vars.filename in JS activity just after the extract in a specific variable (such as instance.vars.yourvariable above) and do some custom JS after each activity changing the vars.filename value.

For example, if you have 2 extract activities, you can attach the 2 files as is:

delivery.attachment.add(
  <attachment compressMode="print" filterActive="false" label="my label first file"
              nameScriptActive="false" type="normal" upload="false">
    <name>{instance.vars.myfirstfilename}</name>
  </attachment>)

delivery.attachment.add(
  <attachment compressMode="print" filterActive="false" label="my label second file"
              nameScriptActive="false" type="normal" upload="false">
    <name>{instance.vars.mysecondfilename}</name>
  </attachment>)

delivery.hasAttachments = true

Hope this helps.
Regards
J-Serge

RaaghuikAuthor
Level 2
March 6, 2019

Hi Jean,

Can you explain me this "instance.vars.mysecondfilename".

Regards,

Raaghu

Jean-Serge_Biro
Level 10
March 6, 2019

Hi Raaghu,

I didn't want to mislead you.

In simple case, one extract activity, followed by a delivery activity: just use vars.filename.

In complex cases, with several files to attach to the email delivery, or other operation on files (such as compressing and gathering into the zip several files), you can manage it by different variables, storing the factory vars.filename in instance variables to manage the final filename to use for the delivery.
But forget these cases if you don't need them.

Regards
J-Serge

Level 3
March 6, 2019

I guess you could use following steps.

1. Your Workflow.

2. File Transfer Activity

3. delivery view

4.Your server file details goes here

Follow these steps

Regards.

RaaghuikAuthor
Level 2
March 6, 2019

Hello,

Thanks for the reply, Here my concern is how to export a file to server so that i can specify the path of the file in the delivery attachment.

Regards,

Raaghu

RaaghuikAuthor
Level 2
March 6, 2019

Let me elaborate the issue,

In the attachment you can see there are 5 records as DSU & it contains Name & Email of the operator, Now I need to extract those 5 records as CSV file,hence I was using the Extraction activity & please note I dont have any file in my local system to upload, I have to convert the data in temp worktable as CSV & need to upload it to server & then i can attach to delivery.

The problem here is how to export worktable data as csv file to the server & to get the path of it.

Jean-Serge_Biro
Jean-Serge_BiroAccepted solution
Level 10
March 6, 2019

Hi Raaghu,

Please do what I mentioned above:

1. add a Delivery activity (NOT a continuous delivery), based on a Delivery Template (model) in which you select the To field as population coming from workflow.

2. In the wfk delivery activity, click on the 2nd tab (Script tab), then paste this:

delivery.attachment.add(
  <attachment compressMode="print" filterActive="false" label="my label"
              nameScriptActive="false" type="normal" upload="false">
    <name>{instance.vars.filename}</name>
  </attachment>)

delivery.hasAttachments = true

That's all

February 21, 2024

Hi Jean,

Checking this post after 4 years.

I am getting an error doing so.

Are my below steps correct?

  1. I have a data extract activity where File Name = <%= vars.filename %>
  2. I have a delivery envelope where in the script tab , I’ve added your script.

Are above 2 steps enough? if yes then i am getting error

OR

Do I have to click on attachment in the delivery and add attachment without uploading fiel to server?

Do I have to click on attachment in the delivery and add attachment and upload sample file on server? – which file to upload and what should be the file name

 

Thanks in advance

 

Best

Vedant

 

RaaghuikAuthor
Level 2
March 7, 2019

Hi Jean,

I followed the steps you mentioned & I am getting an error in the Delivery