2

I am trying to get a Sitecore contact with the custom facet. The custom facet is working fine I have verified it. The following code is running fine on Standalone and CM environment but is throwing error on the CD environment.

var contact = client.Get(reference, new ContactExpandOptions(EqActivityFacet.DefaultFacetKey)); var facet = contact.GetFacet<EqActivityFacet>(EqActivityFacet.DefaultFacetKey);

ERROR: The specified type does not match the facet at Sitecore.Xconnect.Entity.GetFacet[TFacet](String name)

3

You need to perform the below steps to achieve this:

  1. Create a Custom Facet Model
  2. Register the Custom Facet Model Deploy
  3. Custom Facet model to XDB
  4. Add it to the Sitecore.XConnect.Client.Configuration

Please refer below both the blogs and verify if you missed anything.

Create Custom Facet Model in Sitecore 9

Work with Custom Facet in Sitecore 9

Let me know in case you need further help.

7
  • There is no problem in Contact Facet Model becuase the CM and CD share the same Xconnect environment and it is working fine in CM. I am facing this issue in CD environment. @Himmat Singh Dulawat – Gautam Aneja Apr 7 '20 at 11:44
  • 1
    Sounds like you are missing config files for your facet on the CD server(s). – Chris Auer Apr 7 '20 at 14:59
  • Can you please tell which config files should be added to CD server? @Chris Auer – Gautam Aneja Apr 7 '20 at 16:16
  • 1
    The schema config I reference in my answer below. – Chris Auer Apr 7 '20 at 16:38
  • 2
    Please refer to "Deploy the model to core roles" section in this page, doc.sitecore.com/developers/93/sitecore-experience-platform/en/… – Chris Auer Apr 7 '20 at 17:32
2

The schema that you specified does not match the JSON that is on xConnect. Have you built the BuildModel correctly?

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

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

        modelBuilder.ReferenceModel(Sitecore.XConnect.Collection.Model.CollectionModel.Model);

        modelBuilder.DefineFacet<Contact, RegistrationDataFacet>(RegistrationDataFacet.DefaultFacetKey);

        return modelBuilder.BuildModel();

    }
}

This JSON should match your schema config

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <xconnect>
            <runtime type="Sitecore.XConnect.Client.Configuration.RuntimeModelConfiguration,Sitecore.XConnect.Client.Configuration">
                <schemas hint="list:AddModelConfiguration">
                    <schema name="registrationdatamodel" type="Sitecore.XConnect.Client.Configuration.StaticModelConfiguration,Sitecore.XConnect.Client.Configuration" patch:after="schema[@name='collectionmodel']">
                        <param desc="modeltype">Sitecore.Feature.Registration.Model.RegistrationDataModel, Sitecore.Feature.Registration</param>
                    </schema>
                </schemas>
            </runtime>
        </xconnect>
    </sitecore>
</configuration>
1
  • everything is fine on CM environment which is using the same XConnect environment but I am facing this issue on CD. models are created correctly. @Chris Auer – Gautam Aneja Apr 6 '20 at 22:21
0

Custom facets are not getting registered on one of the environments, it could be because of incorrect deployment of configs files.

  1. After creating Custom Facet Model and serializing the collection model into JSON, you'll need to deploy the JSON file to
  • path_to_xconnect\App_data\Models
  • path_to_xconnect\App_data\jobs\continuous\IndexWorker\App_data\Models
  1. Deploy your Custom facet class project dll at the following places:
  • path_to_xconnect\App_data\jobs\continuous\AutomationEngine\
  • path_to_xconnect\App_data\jobs\continuous\IndexWorker\
  • path_to_xconnect\bin
  • Instance_Name.sc\bin (CM and CD)
  1. Create a configuration patch file at: Instance_Name.sc\App_Config\Sitecore\XConnect.Client.Configuration. You are free to choose any file name. eg. Sitecore.XConnect.CustomFacetClient.config

enter image description here

  1. Deploy the model to the Marketing Automation Engine: Create a configuration file named sc.Demo.CustomModel.xml at path_to_xconnect\App_Data\jobs\continuous\AutomationEngine\App_Data\Config\sitecore\MarketingAutomation_patch. The file name must start with sc and end with .xml. Paste the following model configuration and make the following changes: enter image description here

Note: You’d need to create a new folder named MarketingAutomation_patch under AutomationEngine\App_Data\Config\sitecore to store all the patch files under one folder.

You can find detailed steps here: https://sitecorehacks.wordpress.com/2020/08/02/sitecore-xconnect-custom-facets-part-i/

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.