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
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:
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.
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.
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.
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.