How do you update null ExtendedDetail in Tridion audience manager contact?

I have code that works with contacts through Tridion.AudienceManagement.API. When working with existing contacts, some of them will have different ExtendedDetail than others. I am having problems when I want to fill in a value that doesn't matter yet

 var extendedDetail = contact.ExtendedDetails[fieldName]; if (extendedDetail == null) { // What do I do here? } 

The problem is that when this ExtendedDetail is null, I have no way to set its value. The code examples in the documentation do not cover this example, and the API documentation does not explain what null ExtendedDetail means, not to mention how to create it, and fill it correctly.

+4
source share
2 answers

You need to get / set ExtendedDetails values ​​with .Value .

 var extendedDetail = contact.ExtendedDetails[fieldName].Value; if (extendedDetail == null) { contact.ExtendedDetails[fieldName].Value = "VALUE" } 

For reference, please take a look at the documentation ".NET Auditor API" (chm) and check the "ExtendedDetail" class for some examples.

UPDATE: I have not seen the script when ExtendedDetails will be null. I checked the following minimum data to create a contact and then get the extended data. When you create a contact, you need to have IDENTIFICATION_KEY and IDENTIFICATION_SOURCE , which are required and are part of ExtendedDetails , so you should never run this script.

 //Create a Contact with basic data.. Contact contact = new Contact(); contact.EmailAddress = "abc @123.com "; contact.SubscriptionStatus = SubscriptionStatus.Subscribed; contact.ExtendedDetails["IDENTIFICATION_KEY"].Value = " abc@123.com "; contact.ExtendedDetails["IDENTIFICATION_SOURCE"].Value = "Website"; contact.Save(); // UPDATE the User Profile .. ContactId = new string [] { " abc@123.com ", "Website" }; Contact contact = Contact.GetFromContactIdentificatonKeys(ContactId); contact.ExtendedDetails["NAME"].Value = "NAME"; 

Could you post a code on how you create a contact?

+4
source

If your extended part is NULL, this is probably because you are trying to specify a field that is actually missing. Perhaps you made a mistake, or your database table is not updated, or recent changes you made to the database have not yet been collected (the collection of advanced information is heavily cached for obvious reasons).

In short, if an extended part is defined in the database, it will be available in this collection, so it will not be zero.

+2
source

All Articles