Level 1
Level 2
Melden Sie sich an, um alle Badges zu sehen
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;
Gelöst! Gehe zu Lösung.
Anhand von Themen werden Community-Inhalte kategorisiert und Sie können so relevanten Inhalt besser finden.
Zugriffe
Antworten
Likes gesamt
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.
Zugriffe
Antworten
Likes gesamt
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.
Zugriffe
Antworten
Likes gesamt
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.
Zugriffe
Antworten
Likes gesamt
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"
Zugriffe
Antworten
Likes gesamt
@kl28morr That means you Initial code isn't working
vars.deliverylabel = targetData.@deliverylabel;
Zugriffe
Antworten
Likes gesamt
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:
Zugriffe
Antworten
Likes gesamt
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!
Zugriffe
Antworten
Likes gesamt
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!
Zugriffe
Antworten
Likes gesamt
Zugriffe
Likes
Antworten
Zugriffe
Likes
Antworten