Avatar

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