0

We are having Custom Facet with Complex type in 8.2, that needs to be Migrated to Sitecore 9.3

Followed below Link for creating facet.

https://doc.sitecore.com/en/developers/91/sitecore-experience-platform/create-a-custom-facet.html

How to Migrate Custom Facet with complex type from SC8.2 to SC9.3 ?

Facing Difficulties When Configuring Nested Complex Properties

Below is the code Example:

[Serializable]
[FacetKey(DefaultFacetKey)]
public class MyProjData : Facet
{
    public const string DefaultFacetKey = "MyProjData";

    public int PersonId
    {
        get; set;
    }

    public MyProjCentralData MyProjCentralData
    {
        get;set;           
    }

    public MyProjData()
    {
        
    }
}


[Serializable]
public class MyProjCentralData
{       
    public Preferences Preferences
    {
        get;set;
    }
    public List<Bookmark> Bookmarks { get; set; } = new List<Bookmark>();

    public List<FavoriteTool> FavoriteTools { get; set; } = new List<FavoriteTool>();

    public List<LikedContent> LikedContent { get; set; } = new List<LikedContent>();
   
    public MyProjCentralData()
    {            
    }
}

[Serializable]
public class Preferences
{
    public string SearchResultsFormat
    {
        get; set;
    }

    public DateTime WatchedIntroTourDate
    {
        get; set;            
    }
    public List<TourView> TourViews { get; set; } = new List<TourView>();

    public List<DocumentLanguageFilter> DocumentLanguageFilters { get; set; } = new List<DocumentLanguageFilter>();

    public List<DocumentRegionFilter> DocumentRegionFilters { get; set; } = new List<DocumentRegionFilter>();
    
    public Preferences()
    {           
    }
}

[Serializable]
public class FavoriteTool : IFavoriteTool
{

    public DateTime DateAdded
    {
        get; set;
    }

    public DateTime LastAccessed
    {
        get; set;
    }

    public Guid ToolId
    {
        get; set;
    }

    public int VisitCount
    {
        get; set;
    }

    public FavoriteTool()
    {
    }
}
0
1

You can use XDB migration tool to migrate data from MongoDB to xDB. To migrate complex and custom types, you must register a custom migration model.

1. The first step is to create a model in xConnect: In the older version (8.x), you might have a facet class implemented from IFacet, now in 9.x you need to create a custom facet model class implementing from Facet interface and then register the model class in CollectionModel.

You can follow this blog to create a model in xconnect: https://sitecorewithraman.wordpress.com/2020/08/02/sitecore-xconnect-custom-facets-part-i/

2. Next Step is to Configure a custom facet in the Data Exchange Framework: After creating the Facets and Model, register the model with Data Exchange Framework. To do that:

  • In the Content Editor, go to /sitecore/System/Settings/Data Exchange/Providers/xConnect/Collection Models, and create a new model.
  • Create simple value accessor sets for the MongoDB and xConnect AvailablePublisher Entry models using the MongoDB Document Field Value Accessor and xConnect XObject Property Value Accessor.
  • In the content tree, go to /sitecore/System/Data Exchange//Value Mapping Sets/MongoDB. Use the value accessors you created to create a one-to-one mapping for the MongoDB collection entry to the xConnect Facet Dictionary entry.
  • Add the AvailablePublishers value accessor for a source contact.

3. Configure the mappings for the custom facet:

  • Go to /sitecore/System/Data Exchange//Data Access/Value Readers/Providers/MongoDB and create Dictionary Entries from the document value reader for AvailablePublishers.
  • Go to /Data Access/Value Accessor Sets/Providers/MongoDB/Create a Value Accessor Set, select the general Value Accessor and assign the value reader you created to this accessor.
  • On the xConnect Provider, use the xConnect Entity Facet Value Accessor and xConnect Entity Facet Dictionary Property Value Accessor templates to create an accessor for the AvailablePublishers facet and an accessor for the AvailablePublishers Dictionary facet property.
  • Create a mapping set between the value accessor and the Facet AvailablePublishers Dictionary property value accessor.
  • Add a mapping between MongoDB AvailablePublishers and the xConnect AvailablePublishers.

4. Map contact data in MongoDB to an xConnect contact facet:

  • Navigate to Endpoints / Providers / xConnect / xConnect Client Endpoint and click click Show Deployed Models in the toolbar.
  • In the popup window, the custom model you created and deployed to xConnect should appear. Click OK.
  • In the Collection Model field, select the custom model you created.Save the Item.

Look at the Sitecore Documentation for more details: https://doc.sitecore.com/en/developers/dmt/40/xdb-data-migration-tool/walkthrough--migrating-a-custom-facet-with-complex-types.html

2
  • Sitecore doc talks about top level Complex type, but in our case we have many nested Complex types, facing difficulties to map these nested Complex types. I have created Value Accessor sets for all nested Complex properties in MongoDB and Xconnect, and created Mapping between these two. After this step i will to have to create connection between XConnect Entity Facet and Mapping set, here i can create for direct Complex property in Facet, but how to do same for Nested Complex property ? Sep 24 '21 at 8:36
  • I have updated the post with code example, Facing Difficulties to configure Nested Complex Properties. Sep 24 '21 at 8:45
0

Sitecore XConnect provides some default collection models to save user data like Personal Information, Email, Address, etc. the complete list you can find in an assembly named Sitecore.XConnect.Collection.Model.dll.

You need to perform the below-mentioned steps to create custom facets in Sitecore.

  1. Create a Custom Facet Model
  2. Register the Custom Facet Model
  3. Deploy custom Facet model to XDB
  4. Add Custom Facet Model to Configuration

You can find step by step details about the above points from here: create-custom-facet-model-in-sitecore-9

Now next point is once you created the Custom facets then How will you use those? For the same you can follow the below blog:

work-with-custom-facet-in-Sitecore

Let me know in case you find any trouble, I am glad to help you.

1
  • I have updated the post with code example, Facing Difficulties to configure Nested Complex Properties. Sep 24 '21 at 8:45
0

Between sitecore 8.2 and 9.3 is a huge difference between the xdb models. Starting from Sitecore 9 it was added xConnect.

First time you need to create xdb custom facets like on the link you added.

Then you need to install xdb migration tool module which is compatible with Sitecore 9.3 https://dev.sitecore.net/Downloads/Sitecore_xDB_Data_Migration_Tool/4x/xDB_Data_Migration_Tool_400.aspx

Then you need to start working on migration of xdb contacts+custom facets.This is the difficult part.

These are the steps you need to follow:

1.Determine the data to migrate

2.Determine where to store the migrated data

3.Implement components to store migrated data

4.Create facet

5.Create model

6.Deploy components to the Sitecore server

7.Register model with Data Exchange Framework

8.Deploy model to xConnect

9.Map data from MongoDB to contact facet

10.Update the xConnect endpoint

11.Update the pipeline step that resolves the contact model

12.Specify data to read from MongoDB

13.Specify data to write to xConnect contact facet

14.Configure mapping from MongoDB contact to xConnect contact facet

15.Specify how xConnect contact facet is populated

16.Add mapping for xConnect contact facet to entity model for contact

17.Run pipeline batch

18.xConnect collection database

19.xConnect search

Here you find more information :

https://doc.sitecore.com/en/developers/dmt/40/xdb-data-migration-tool/adding-custom-data.html https://doc.sitecore.com/en/developers/dmt/40/xdb-data-migration-tool/entity-facets.html

1
  • I have updated the post with code example, Facing Difficulties to configure Nested Complex Properties. Sep 24 '21 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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