Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Campaign Delivery- Attachment

Raaghuik
Level 2
Level 2

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

1 Accepted Solution
Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor

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

View solution in original post

19 Replies
Jonathon_wodnicki
Community Advisor
Community Advisor

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
Level 2
Level 2

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

Jean-Serge_Biro
Community Advisor
Community Advisor

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

Raaghuik
Level 2
Level 2

Hi Jean,

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

Regards,

Raaghu

Jean-Serge_Biro
Community Advisor
Community Advisor

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

asariaaara
Level 4
Level 4

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.

Raaghuik
Level 2
Level 2

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
Level 2
Level 2

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

Jean-Serge_Biro
Correct answer by
Community Advisor
Community Advisor

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

View solution in original post

Raaghuik
Level 2
Level 2

Hi Jean,

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

g.JPG

h.JPG

i.JPG

J.JPG

k.JPG

Raaghuik
Level 2
Level 2

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.

Jean-Serge_Biro
Community Advisor
Community Advisor

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

pratibham904108
Level 1
Level 1

Hi i am also getting error in delivery. Can you please tell me how did you resolve that error?

Raaghuik
Level 2
Level 2

Hi Pratibha,

Can I know what exactly the error you are mentioning about

Regards,

Raaghu

Raaghuik
Level 2
Level 2

Hi pratibham90410856,

Can I know what exactly the error you are mentioning about

Regards,

Raaghu

pratibham904108
Level 1
Level 1

Hi,

i have attached screenshot for error snapshot which am getting in delivery. Please check the attachment and help me to resolve my issues.

delivery error.PNGdeliveryscript.PNGexportworkflow.PNG

pratibham904108
Level 1
Level 1

PFA delivery script  which i have written in email delivery.deliveryscript_updated.PNG

Raaghuik
Level 2
Level 2

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