Use of Javascript variables in delivery | Community
Skip to main content
Level 4
October 9, 2025
Solved

Use of Javascript variables in delivery

  • October 9, 2025
  • 3 replies
  • 411 views

Hi,

 

I have created one simple workflow in which first activity is JS Code - here, I am trying to store value in instance variable. I have logged this and it is showing under journal. Second acitivity is query in which I am fetching test account and this is working. Third activity is the recurring delivery. I am trying to show instance variable in this delivery. I have added "script" in this delivery and I have also added "variable" under properties.

 

However, emails are not being sent at all.

 

I have followed step as per URL - https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-classic/tuesday-tech-bytes-adobe-campaign-classic/m-p/627479/highlight/true#M2588

 

@parthasarathy - can you please help?

 

JS Code

 

1. instance.vars.temp = functioname('parameters');

2. logInfo(instance.vars.temp);

 

Query

 

1. Temp player ID

 

Delivery

 

HTML:

Data is <%= variables.temp %>

 

Script:

delivery.variables._var[0].stringValue=instance.vars.temp;

 

Variables under properties:

"temp"

 

Best answer by SorenDP

Hi! It is not feasible in my experience to write to delivery variables from JS like that. Instead you could create an additional variabel in your query and set the value to the instance.vars.test value. Then you can simply reference <%=targetData.temp%> in the delivery. This is tested and works like a charm 🙂 

So: 


  1. JS activity "instance.vars.test = 'some random text';"
  2. This is the additional data tab of the query element. Set the datafield to the value of the JS defined value like this: 

3. Rerefence that variable in the delivery with "<%=targetData.temp%>"

Hope that helps! 

 

3 replies

vinay16Author
Level 4
October 14, 2025

Can anyone please help ?

RCh2_
Level 2
October 14, 2025

Hey @vinay16,

 

Your setup looks mostly correct from what you shared.

To help pinpoint the issue, could you please share the exact function (functioname) you’re using in your JS activity? Also, if you can check and share any errors or details from the delivery audit tab, that would be super helpful.

Sometimes the problem comes down to what the function returns—whether it’s a string, object, or function—which affects how you assign it to the delivery variable.

Happy to take a closer look once you share that info!

Thanks,

vinay16Author
Level 4
November 10, 2025

There are no errors under audit tab. And fuction returns integer values separated by commas (,).

SorenDPAccepted solution
Level 4
October 15, 2025

Hi! It is not feasible in my experience to write to delivery variables from JS like that. Instead you could create an additional variabel in your query and set the value to the instance.vars.test value. Then you can simply reference <%=targetData.temp%> in the delivery. This is tested and works like a charm 🙂 

So: 


  1. JS activity "instance.vars.test = 'some random text';"
  2. This is the additional data tab of the query element. Set the datafield to the value of the JS defined value like this: 

3. Rerefence that variable in the delivery with "<%=targetData.temp%>"

Hope that helps! 

 

vinay16Author
Level 4
November 10, 2025

I know this method and this works well. However, I was trying to use the method explained in above shared experience league page. It did not work.

 

Also, for this method, is there anyway to check whether the value of targetData.variable name exists or not prior to displaying that in delivery.