Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards

Pass key-value object to display content in recurring delivery

Avatar

Level 1

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

3 Replies

Avatar

Level 4

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-fi...

 

Thanks

Sushant Trimukhe

Avatar

Level 1

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?

Avatar

Administrator

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