Hello,
I am trying to set a variable using targetData in Javascript. My code looks like this but I keep getting "targetData not defined" error message. I've confirmed my targetData and the alias is correct. Any ideas? I will need to use the vars.deliverylabel in a file name in a file export activity.
// Get delivery label
vars.deliverylabel = targetData.@deliverylabel;
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hey @kl28morr Since your target dimension has multiple records. The targetData won't work in this.
You will have to split the audience based on deliveryLabel and then make that value static.
Views
Replies
Total Likes
I tried this but still getting the same error:
// Get delivery label
vars.deliverylabel = targetData.deliverylabel;
04/30/2025 10:55:24 AM SCR-160012 Javascript: error while evaluating script 'WKF14851/js'.
04/30/2025 10:55:24 AM JST-310000 Error while compiling script 'WKF14851/js' line 3: targetData is not defined.
Views
Replies
Total Likes
Hello @kl28morr
I believe you are trying to name the file based on the delivery Label. If that is your use-case then do this.
Use <%= vars.deliveryLabel %> in the file name.
Views
Replies
Total Likes
Hi @_Manoj_Kumar_ when I do that, I am getting "undefined" in the file name.
I have my delivery activity then a few other activities after, including enrichments, then finally doing a file export where I am referencing file name as you mentioned:
<%= vars.deliveryLabel %>_<%= formatDate(new Date(), "%4Y%2M%2D") %>.txt
the file name is "UNDEFINED_20250501"
Views
Replies
Total Likes
@kl28morr That means you Initial code isn't working
vars.deliverylabel = targetData.@deliverylabel;
Views
Replies
Total Likes
Do you mean where I am defining the targetdata is not working?
This is where I am defining the targetData -
This is how i am setting the vars (right after the above enrichment using a Javascript activity)
I also removed the "@" symbol per ParthaSarathy comment and then calling it in my file export file name:
Views
Replies
Total Likes
Hi @_Manoj_Kumar_ and @ParthaSarathy,
Would you be able to support @kl28morr further on this, or should we escalate it to our internal SMEs? Let me know what do you think.
Thanks!
Views
Replies
Total Likes
Hey @kl28morr Since your target dimension has multiple records. The targetData won't work in this.
You will have to split the audience based on deliveryLabel and then make that value static.
Hi Manoh,
sorry for the delayed response. When you say make the value static - you mean to hardcode it manually? There is no way to pull the delivery label dynamically within each workflow? I am trying to avoid having to change it every time. Thanks!
Views
Replies
Total Likes
Views
Likes
Replies