To Read a variable in Delivery activity - Adobe Campaign

Jaspreet_Kaur1

08-09-2017

Hello,

I have defined a variable in the Campaign WF( vars.fileName) and trying to read that variable in the delivery activity's(DM) file name(in the extraction Tab) (<% = vars.fileName %>)and getting error in delivery mentioned below-

The delivery has failed

XSV-350122 An error occurred and the process has been stopped. SOP-330011 Error while executing the method 'PrepareTarget' of service 'nms:delivery'. SOP-330011 Error while executing the method 'PrepareTargetImpl' of service 'nms:delivery'. DLV-490017 Error while computing the output file name. JavaScript: error while evaluating script 'outputScript'. JST-310000 Error while compiling script 'outputScript' line 5: vars is not defined.

Can someone pls guide, how can I fetch it?

Accepted Solutions (1)

Accepted Solutions (1)

Jean-Serge_Biro

MVP

14-09-2017

Hi Jaspreet,

Thanks to your screenshot, by now I understand that you leverage External postal mail delivery mode, not Email delivery mode, well sorry for my previous post which was written with Email delivery mode in mind.

First of all, I think the JS filename calculation is fine, it is not a question of instance type variable, it works fine with standard events type var as well.

Here is my workflow:

1298904_pastedImage_0.png

Here is my Javascript activity content to simulate your own one (you need complex calculation so I don't recommend to do it in the Delivery script tab):

vars.calculatedFilename = "D:\Temp\jserge_courrier_externe.csv" ;

Here is my Delivery script content:

delivery.variables._var[0].stringValue = vars.defaultFilename;

Here is my Delivery template file definition:

1299028_pastedImage_1.png

And in the Property tab of the Delivery Template, I define my variable as is:

1299032_pastedImage_2.png

So this configuration works fine and does your requirement.

Please note I define a default value in the Variables of Delivery template,  so it is easier to do Proof and tests outside workflows execution.

Regards
J-Serge

Answers (7)

Answers (7)

Jean-Serge_Biro

MVP

15-09-2017

2 more things:

I failed to use directly delivery.output.fileName in Delivery script tab, but someone could probably optimize my solution by using delivery.output.fileName directly, instead passing the vars.calculatedFilename value defined in the JS activity to the delivery thanks to the Delivery variable defined.

If you have already defined some variables in your delivery, please note that the variables order is important, so adapt it accordingly in the Javascript code (_var[0] for 1st variable defined, _var[1] for the 2nd one, and so forth).

Regards
JS

Jaspreet_Kaur1

18-09-2017

Many Thanks Jean.

The portion I was missing - Declaring of the variable in Delivery.

Also, the syntax I used to read the variable was incorrect. Instead of <%= vars.fileXyz %> it should be <%= variables.fileXyz %>.

Its working now. Thanks a lot..

Jaspreet_Kaur1

14-09-2017

Basically, I am creating a file name in a JS script(based on the country name which I am getting from one of the schemas), putting that in a variable(tried with the instance variable too and changed the file name as well to avoid any confusions ) and trying to fetch that file name variable in the delivery activity,which I am using post this JS activity. In between these act two activities , I have few mandatory checks, implemented using various  other activities.

Definition of the variable in the JS-

instance.vars.xyzFile = 'TEST_' + 'GBR_' + vars.CompNam1 + '.csv';

Using delivery activity as I need to extract few other fields from that schema, including some codes, else could have used Extract

1298746_pastedImage_1.png

The strange thing is, this variable is getting fetched correctly, at  from the script tab of the delivery activity.

1298768_pastedImage_2.png

Hope its much clearer now.:) We can have a  quick call, if needed.

Jean-Serge_Biro

MVP

11-09-2017

Hi Jaspreet,

Sorry, now it is unclear for me what you intend to achieve.
Please may you share 2 screenshots: the workflow itself, and the activity "extract tab" where you try to put your personalisation code.

Because your fileNameOnly variable is constituted with a .csv extension, I guess it is in a Extract file activity in which you want to export something, probably the Delivery logs?

(in that case take care to wait for a few days for completing the delivery before leveraging the broadlogs.)

But the error you gave in your 1st post is during the delivery preparation, so the only true file so filename that I know are for attached file to a delivery message. Is it the case?

In that latter case, you must have something like this in your Delivery script tab (this is not a "extract" tab as you mentioned in your post), assuming you have generated the csv file before the delivery.

// csv file to attach to delivery messages

delivery.attachment.add(

  <attachment compressMode="print" filterActive="false" label="extractDeliveryEmail"

              nameScriptActive="false" type="normal" upload="false">

    <name>{vars.filename}</name>

  </attachment>)

 

delivery.hasAttachments = true

1296585_pastedImage_0.png

In that use case, the csv file is the same for all delivery messages (all contacts receive the same file).

In other use cases where people receive personalised attached files (PDF or pre-generated on server), you should use the Detail form of the Attach file form in the delivery template

1296587_pastedImage_1.png

Regards

J-Serge

Jaspreet_Kaur1

08-09-2017

Thanks Jean for your inputs

Its a typo while i wrote here, however, its mentioned correctly in Campaign i.e without space.

Also, I am calculating the file name based on my inputs like - vars.fileNameOnly = 'TEST_' + vars.CompNam1 + '.csv'; in the previous JS node and can see the proper output in the log, but its failing everytime when I use it in Delivery.

Using this in delivery-

<%= vars.fileNameOnly %>

The strange thing is when I use the other variables like - Add current date - which is inbuilt ( <%= formatDate(new Date(), "%2D/%2M/%2Y") %>), its working perfectly fine.

Also, in the script tab of delivery, I tried reading it- vars.fileNameOnly and its coming fine in the log.

Anything wrong with my template?

Jean-Serge_Biro

MVP

08-09-2017

Hi Jaspreet,

Please may you check if there is an extra white space in your codebetween % and = glyphs, or only in your ticket post?

I read:

<% = vars.fileName %>

(extra blank)

instead of:

<%= vars.fileName %>

(correct syntax).

If this was not due to mistype that I guess, please may you share a screenshot for Delivery scripting?

By the way, why do you define a variable vars.fileName, why don't use the standards event variable vars.filename (with N uppercase)?

Regards.
J-Serge