8

using Sitecore Data Exchange Framework v1.4.1, let's assume you want to add hundreds of emails to xDB Contact > Emails facet. How would you configure DEF to add each address to the IElementDictionary<IAddress> Entries property in Addresses facet?

I am assuming "xDB Contact Facet Collection Property Value Accessor" plays a role, but how do you set it all up? You can set the collection property in it. But how do i make sure i map the fields in the IEmailAddress that is added to the collection?

any example anywhere? any ideas?

Edit 10/19/17: I do know how to add data to xDB through code. What I need is information on how to configure Sitecore Data Exchange Framework to map and import data into collection. I guess, I can simplify it once more by going back to my title and ask, how do you configure and use "xDB Contact Facet Collection Property Value Accessor" in Data Exchange Framework? Let's just forget everything else I said and simply provide me an example of how to use "xDB Contact Facet Collection Property Value Accessor" in Data Exchange Framework? What is that Value Accessor used for? Where are the examples on how to use this thing?

2
  • 1
    If you would like to iterate each email you can extend value accessor with field linked to Mapping Set. Accessor value writer where value is "source collection" and target is "IElementDictionary<IAddress> Entries" iterates each source element and runs Mapping Set. Mapped element adds to Entries collection.
    – Vlad Shpak
    Oct 19, 2017 at 7:48
  • i can probably extend current DEF value accessor and get it to work but i am wondering what is "xDB Contact Facet Collection Property Value Accessor" used for? you can set "Contact Facet Name" and Collection "Property Name", so there must be some way to map collection item fields and then pass that info to this value accessor somehow.
    – emer
    Oct 19, 2017 at 17:20

2 Answers 2

2

For example:

 var addressesFacet = contact.GetFacet<IContactAddresses>("Addresses");
            if (addressesFacet != null && !addressesFacet.Entries.Contains("Preffered Address"))
            {
                var address = addressesFacet.Entries.Contains("Preffered Address")
                    ? addressesFacet.Entries["Preffered Address"]
                    : addressesFacet.Entries.Create("Preffered Address");
                address.Country = contactModel.Country;
                address.PostalCode = contactModel.ZipCode;
                addressesFacet.Preferred = "Preffered Address";
            }

You can add all your address to Addresses facet or update existing address.

Don't forget to set Preferred address which Sitecore will use as a default address for contact

1
  • 2
    thank you, but this is not what i need. i understand how to do this via code. my question is regarding Sitecore Data Exchange Framework and "xDB Contact Facet Collection Property Value Accessor".
    – emer
    Oct 19, 2017 at 17:15
1

Here is an example how "xDB Contact Facet Collection Property Value Accessor" works. Have a look at this value accessor configuration.

enter image description here

It tries to:

  1. Get DynamicsCrm facet.
  2. In found facet get MarketingLists collection property
  3. Writer uses Collection Value Appender that tries to add value to a MarketingLists collection.

public List<Guid> MarketingLists {get;set;}


object value = Guid.NewGuid();
MarketingLists.Add(value);

If "Do Not Use Value Appender is set" it tries to:

  1. Get DynamicsCrm facet.
  2. In found facet get MarketingLists collection property.
  3. Writer tries to set value to MarketingLists property if value is the same type.

    object value = List<Guid>(){Guid.NewGuid(),Guid.NewGuid()};
    MarketingLists = value;

2
  • but let's say you have this instead: public List<MarketingList> MarketingLists {get;set;} and MarketingList has Property1 and Property2. How do i map a value to Property1 and Property2 and add it as new collection item in MarketingLists?
    – emer
    Oct 23, 2017 at 21:06
  • 1 approach. Create custom template based on xDB Contact Facet Collection Property Value Accessor and add Value Mapping Set field and update accessor where reader iterates source list, run mapping set to map inner properties and add mapped object to a target collection. 2 approach. Use Source Value Transformer - value reader used to convert the source value into a format that can be written to the target object.
    – Vlad Shpak
    Oct 23, 2017 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.