Pass key-value object to display content in recurring delivery | Community
Skip to main content
April 29, 2025
Question

Pass key-value object to display content in recurring delivery

  • April 29, 2025
  • 1 reply
  • 574 views

Hello,

 

I'm trying to pass dictionary key-value object to display personalized content in recurring delivery and I'm not sure how to do so.

 

General idea is that first I'm querying my database and then I'm using javascript activity to:
1. Get customerIds from targetSchema
2. Do some calculations through third party API
3. Save the results in key-value pairs, one value per one recipient, for example:

 

var dictionary = { 'customerId021': 'value1', 'customerId525': 'value2', 'customerId333': 'value3' };

 

up to this point everything is fine and now I wanted to pass this object to vars event variable to use it in recurring delivery activity, so in my javascript I did the following:

vars.contentDictionary = dictionary;

and in my delivery I was planning to do something as follows:

<%= vars.contentDictionary.consumerId %>

so the content would display different value per each user based on his consumerId.

 

Unfortunately this is not working as expected as after the line:

vars.contentDictionary = dictionary;

this new object is not working in the same way as previous javascript object:

 

logInfo(vars.contentDictionary); >> 04/29/2025 10:53:10 AM js [object Object]for each (var e in vars.contentDictionary) { logInfo(vars.contentDictionary[e]); } >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined >> 04/29/2025 10:53:10 AM js undefined

 

So basically I can't figure out how to get specific values from this object after putting it in event variable and also I'm not sure if I can simply use it in recurring delivery activity which follows the javascript or I should perform some extra steps? Any help will be appreciated.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SushantTrimukheD
Level 4
April 29, 2025

Hi @baint,

You could try something like this: First, retrieve all the customer IDs using a query. Then, use an enrichment activity to create an empty field called 'value'. Next, use a JavaScript activity to access the previously queried data using the target schema, call the third-party API to fetch "values" for each customer ID, and populate the 'value' field inside temp schema. This way, you'll have a corresponding 'value' for each customer ID, which you can then use as targetData.value to personalize content inside a delivery.

https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-classic-questions/what-is-the-key-field-for-records-in-a-temporary-schema-how-to/m-p/704533#M23682

 

Thanks

Sushant Trimukhe

BaIntAuthor
May 12, 2025

Hi SushantTrimukheD,

thanks, that seems like a simpler solution indeed. I wanted to do it a bit simpler than in the manual you provided though as I don't really understand why we can't update vars.targetSchema directly instead of saving to temporary schema and then linking it back together. So I tried the following:

var myXML = <queryDef xtkschema={vars.targetSchema} _operation="update" _key="@cusConsumer_id" cusConsumer_id={e.@cusConsumer_id} myValue={e.@myValue} /> xtk.session.Write(myXML);

but unfortunately it doesn't seem to work even though it doesn't throw an error. Just myValue is still empty. On the other hand it works perfectly fine to read data from the vars.targetSchema this way:

var query = xtk.queryDef.create( <queryDef schema={vars.targetSchema} operation="select"> <select> <node expr="@cusConsumer_id"/> <node expr="@myValue"/> </select> </queryDef> ); result = query.ExecuteQuery();

Do you have any idea why this doesn't work as expected?

Sukrity_Wadhwa
Community Manager
Community Manager
May 21, 2025

Hi @sushanttrimukhed,

Would you be able to support @baint further on this, or should we escalate it to our internal SMEs? Let me know what do you think.

Thanks!

Sukrity Wadhwa