4

Version: Sitecore 9.2

I have followed these tutorials:
- https://himmatsinghdulawat.blogspot.com/2019/06/create-custom-facet-model-in-sitecore-9.html
- How to properly configure a custom facet in Sitecore 9.1
- including Sitecore docs and am not seeing my facet key being saved in xDB.

I have checked and both index worker and automation engine are running.

enter image description here

Here is my implementation:

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

    public string Subscribe { get; set; }
    public string Unsubscribe { get; set; }
    public string Property { get; set; }
  }

  public class ContactFacetExtModel
  {
    public static XdbModel Model { get; } = BuildModel();

    private static XdbModel BuildModel()
    {
      XdbModelBuilder modelBuilder = new XdbModelBuilder("ContactFacetExtModel", new XdbModelVersion(0, 1));

      modelBuilder.ReferenceModel(Sitecore.XConnect.Collection.Model.CollectionModel.Model);
      modelBuilder.DefineFacet<Contact, ContactFacetExtension>(ContactFacetExtension.DefaultFacetKey);

      return modelBuilder.BuildModel();
    }
  }

I have placed this in my
- C:\xconnect root\App_Data\Models &
- C:\xconnect root\App_Data\jobs\continuous\IndexWorker\App_Data\Models

ContactFacetExtModel, 0.1.json

   {
  "Name": "ContactFacetExtModel",
  "Version": "0.1",
  "References": [
    {
      "Name": "XConnect",
      "Version": "1.0"
    },
    {
      "Name": "Sitecore.XConnect.Collection.Model",
      "Version": "9.0"
    }
  ],
  "Types": {
    "CustomFacets.ContactFacetExtension": {
      "Type": "Facet",
      "BaseType": "Sitecore.XConnect.Facet",
      "ClrType": "CustomFacets.ContactFacetExtension, CustomFacets, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
      "Properties": {
        "Subscribe": {
          "Type": "String"
        },
        "Unsubscribe": {
          "Type": "String"
        },
        "Property": {
          "Type": "String"
        }
      }
    }
  },
  "Facets": [
    {
      "Target": "Contact",
      "Name": "ContactExt",
      "Type": "CustomFacets.ContactFacetExtension"
    }
  ]
}

Patches made:

   <settings>
      <setting name="ListManagement.Import.FacetsToMap">
        <patch:attribute name="value">Emails|Personal|Addresses|ContactExt</patch:attribute>
      </setting>
    </settings>

    <xconnect>
      <runtime type="Sitecore.XConnect.Client.Configuration.RuntimeModelConfiguration,Sitecore.XConnect.Client.Configuration">
        <schemas hint="list:AddModelConfiguration">
              <schema name="contactfacetextmodel" type="Sitecore.XConnect.Client.Configuration.StaticModelConfiguration,Sitecore.XConnect.Client.Configuration" patch:after="schema[@name='collectionmodel']">
                  <param desc="modeltype">CustomFacets.ContactFacetExtModel, CustomFacets</param>
              </schema>
        </schemas>
      </runtime>
    </xconnect> 

Is my json.config file not being read? What's the best way to debug this? Not seeing anything relevant in the logs.

5
  • Question is, how are you filling this facet? If you don't fill it, it won't appear anywhere. Maybe something is wrong in your code where you use this facet?
    – Joost
    Mar 30 '20 at 8:17
  • I am using it for list manager importing. Mar 30 '20 at 9:57
  • regardless, shouldn't i see my facet key after configuring it in [Xdb.Collection.Shard0].[xdb_collection].[ContactFacets]? Mar 30 '20 at 12:25
  • 1
    You will ONLY see the facet in [ContactFacets] if you write to it. xDB a least possible data container. So null items are not kept in data, since it would take up space in SQL. So unless you are fill it with custom code during your List Manager import, you will never see it in [ContactFacets] table.
    – Chris Auer
    Mar 30 '20 at 14:57
  • 1
    Awesome, thanks. I edited my custom ListManager mapping and the issue has been resolved. Mar 30 '20 at 15:48

Your Answer

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

Browse other questions tagged or ask your own question.