Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!
SOLVED

object only partially available in delivery body within a workflow

Avatar

Level 4

Hi,

I am using the object targetData in a delivery of a workflow. If I try to see what's inside this object with the following code:

document.write("<pre>" + JSON.stringify(targetData) + "</pre>");

I only get part of the object, not all the keys that are available.

However, the keys are perfectly available as if I show them in the way:

document.write(targetData.keyName) 

And the interesting thing is that from that moment, and for any subsequent run, the key keyName is also shown in the JSON.stringify output that I mentioned above.

So, in other words, it looks like JSON.stringify(targetData) don't return anything initially on the first run, but as you start calling the individual parts of the object, then these are available to the JSON.stringify(targetData) for subsequent runs.

I have not only experienced this with JSON.stringify(targetData), but also by calling the value of the object as targetData["keyName"] . This would return undefined unless you have called before (even in a previous run) targetData.keyName.

That behaviour is looking very weird to me!

Anyone can figure out what is happening here?

Thanks in advance

Guillermo

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Guillermo,

object.key and object[key] accomplish the same thing, but Adobe campaign treats them differently.
When you use the object.Key this works because this is hardwired as you are loading only one attribute not all. If you have to This is designed in this way read data from xml when you need it, it is more of on demand system. It is handy when we interact with broadlog(big table, lots of attributes), it loads only part which we need.

If you compare two standards for  Object.keys ( O ) implementation, its algorithm is improved a lot over time

ECMAScript Language Specification - ECMA-262 Edition 5.1

ECMAScript® 2018 Language Specification

If you have loaded the data using additional data, then It should be fixed now. If not, may be you can raise a ticket with Adobe for this?

Regards,

Amit

View solution in original post

5 Replies

Avatar

Level 10

Hi Guillermo,

This is happening because your key value is not available explicitly in targetData. If you want this to work load your keyname using additional data(Additional data ) in the query then this will be available in stringify.

Regards,

Amit

Avatar

Level 4

Thanks for your reply Amit,

I am not sure this is the case. The data is indeed there. It's coming from a data enrichment, and I can always read and use it by using targetData.keyName.

Thanks

Guillermo

Avatar

Level 10

Guillermo, data is there but it's not loaded in the scope(xml) until you explicitly call it. If you are loading all the required attributes using additional data, then it will be available in XML scope.

Regards,

Amit

Avatar

Level 4

Thanks again Amit,

I'm sorry but I don't fully get it. Maybe I have not explained myself properly. I think I have actually loaded the additional data on a enrichment I am using.

The thing is that, from what I know, in javascript it is equivalent to access to an object in the way object.key or object['key'] . I still struggle to understand how can it be that I can use the first and not the second way. And what looks even more weird to me: once I access a value the first way (just assign the value to another variable, or just send it with a document.write ) , I can then freely use both ways. And from that moment, I can even use it both ways in subsequent runs of the workflow without having to use the first way first.

Does it make more sense?

Regards

Guillermo

Avatar

Correct answer by
Level 10

Hi Guillermo,

object.key and object[key] accomplish the same thing, but Adobe campaign treats them differently.
When you use the object.Key this works because this is hardwired as you are loading only one attribute not all. If you have to This is designed in this way read data from xml when you need it, it is more of on demand system. It is handy when we interact with broadlog(big table, lots of attributes), it loads only part which we need.

If you compare two standards for  Object.keys ( O ) implementation, its algorithm is improved a lot over time

ECMAScript Language Specification - ECMA-262 Edition 5.1

ECMAScript® 2018 Language Specification

If you have loaded the data using additional data, then It should be fixed now. If not, may be you can raise a ticket with Adobe for this?

Regards,

Amit