Expand my Community achievements bar.

SOLVED

Using 'to_object' for Map attribute data preparation

Avatar

Level 2

Hi Team,

We have a requirement to ingest data into a map attribute.

Schema have a map attribute field and values will be ingested using Source database dataflows.

I have to use data prep function 'to_object' to ingest data.

While trying out with the sample code provided in document, it is not inserting any values into map field.

Eg: to_object​(“firstName”, “John”, “lastName”, “Doe”) is not ingesting any values.

But, when I used to_object("Test Data",iif(lower(license)=='y',to_object('val','y'),to_object('val','n'))) in ingestion using dataflow, it was showing below result.
Result: [Test Data -> "(NULL,NULL,NULL,y)"]

If I'm referring to documentation, result should be {"Test Data" : {"val":"y"} }

 

Question: Why the result is not showing up for example provided in documentation.

Is there any way that we can validate why to_object​(“firstName”, “John”, “lastName”, “Doe”) is not ingesting any values?

Also, if to_object is not the function that can be used for data prep, which function can be used?

I've referred document https://experienceleague.adobe.com/docs/experience-platform/data-prep/functions.html%3Flang%3Dsv#obj...

 

@derekselby , @arpan-garg , please share your thoughts 

1 Accepted Solution

Avatar

Correct answer by
Moderator

Hi @_abs9900 

 

Map objects are object of array element so can you try ingesting in this way and see if it works -->

 

to_object("Test Data",iif(lower(license)=="y",to_array(true,to_object("val","y")),to_array(true,to_object("val","n"))))

View solution in original post

4 Replies

Avatar

Moderator

Hi @_abs9900 

 

can you please share the schema structure where you want to ingest?

Also if you don't use if-else logic and hardcode the value for testing are you able to preview the result?

 

Avatar

Level 2

Hi @arijitg ,

Thanks for your response.

Currently I'm ingesting data into 'Consent and Preference Details' field group oob attribute - consents.marketing.email.subscriptions

When I try with hard coded values provided in documentation to_object("firstName", "John", "lastName", "Doe"), I can preview the result, but data not getting ingested against attribute when the flow runs.
I've validated data in dataset using query service with below command 

SELECT
consents.marketing.email.subscriptions
from
<datasetname>
ORDER BY
consents.marketing.email.time ASC;

Snapshot of preview screen:

_abs9900_0-1704969741015.png

 

Avatar

Correct answer by
Moderator

Hi @_abs9900 

 

Map objects are object of array element so can you try ingesting in this way and see if it works -->

 

to_object("Test Data",iif(lower(license)=="y",to_array(true,to_object("val","y")),to_array(true,to_object("val","n"))))

Avatar

Administrator

@_abs9900 Did you find the suggested solutions helpful? It would be great if you can  mark the answer as correct for posterity. If you have found out solution yourself, share it with wider audience in the community.