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;
해결되었습니다! 솔루션으로 이동.
토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.
조회 수
답글
좋아요 수
조회 수
답글
좋아요 수
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.
조회 수
답글
좋아요 수
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.
조회 수
답글
좋아요 수
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"
조회 수
답글
좋아요 수
@kl28morr That means you Initial code isn't working
vars.deliverylabel = targetData.@deliverylabel;
조회 수
답글
좋아요 수
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:
조회 수
답글
좋아요 수
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!
조회 수
답글
좋아요 수
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!
조회 수
답글
좋아요 수
조회 수
Likes
답글
조회 수
Likes
답글
조회 수
Likes
답글