Campaign Delivery- Attachment

Raaghuik

05-03-2019

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

Accepted Solutions (1)

Accepted Solutions (1)

Jean-Serge_Biro

MVP

06-03-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

Answers (18)

Answers (18)

Jean-Serge_Biro

MVP

07-03-2019

Hi Raaghu,

Fine:)

Regarding the extract file format, it should be another ticket because it is regarding not the delivery attachement.

Anyway, to make it short, even I don't understand what means "column wise", when default csv format is not convenient, you can choose txt format in Extract activity, even though putting a .csv extension, it allows for more choices about separators, etc.

Regards.
J-Serge

asariaaara

06-03-2019

I guess you could use following steps.

1. Your Workflow.

1706135_pastedImage_0.png

2. File Transfer Activity

1706136_pastedImage_1.png

3. delivery view

1706137_pastedImage_2.png

4.Your server file details goes here

1706141_pastedImage_3.png

Follow these steps

Regards.

Jean-Serge_Biro

MVP

06-03-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

Jean-Serge_Biro

MVP

06-03-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

wodnicki

MVP

05-03-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

Raaghuik

19-08-2019

Hi Pratibha,

Find my attachment bellow I can see some modifications in your script, hence you are getting the error, use the same script as below don't change the "vars.filename"  keep it same as the file name is already provided in data extraction activity you will receive the file with same name as mentioned. It works if you keep things same way as i kept below. Hope this helps

1.JPG

2.JPG

Raaghuik

07-03-2019

Hi Jean,

Finally it worked thanks a lot for the help.

But the problem is the file which is attached is in the CSV delimited with semicolon but I need it in column wise, can you help me on this.

Raaghuik

06-03-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.

f.JPG

Raaghuik

06-03-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

Raaghuik

05-03-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.

e.JPG