1

I have added a new model for my custom facets but it's throwing the following exception while calling the GetClient() method.

One or more local models conflict with the xDB service layer. 'AssemblyFacetKeyModel, 1.0' does not have a remote version'

Model builder class

 public class AssemblyFacetCollectionModel
  {
    public static XdbModel Model { get; } = BuildAssemblyModel();
    private static XdbModel BuildAssemblyModel()
    {
   
      XdbModelBuilder xdbModelBuilder = new XdbModelBuilder("AssemblyFacetKeyModel", new XdbModelVersion(1, 0));
      xdbModelBuilder.ReferenceModel(CollectionModel.Model);
      xdbModelBuilder.DefineFacet<Contact, AssemblyFacetInformation>(AssemblyFacetInformation.DefaultFacetKey); //value >> AssemblyFacetKey
      return xdbModelBuilder.BuildModel();

    }
  }

Custom Facet model class

[FacetKey(DefaultFacetKey)]
  [Serializable]
  public class AssemblyFacetInformation : Facet
  {
    public const string IdentifierCookieName = "_assembly_visitor_id";
    public const string AnalyticsCookieName = "analytics_uuid";
    public const string MetroCookieName = "metro";
    public const string ContactReference = "Assembly_Visitor";
    public const string DefaultFacetKey = "AssemblyFacetKey";
    public const string Timezone = "Timezone";
    public AssemblyFacetInformation() { }

    //[JsonProperty("metro")]
    //public Metro metro { get; set; }
    [JsonProperty("geolocated_location")] //From "metro" Cookie
    public string GeoLocation { get; set; } //From "metro" Cookie
    [JsonProperty("distance_from_metro")]
    public float DistanceFromMetro { get; set; } //From "metro" Cookie
    [JsonProperty("latitude")]
    public float UserLatitude { get; set; } //From "metro" Cookie
    [JsonProperty("longitude")]
    public float UserLongitude { get; set; } //From "metro" Cookie
    [JsonProperty("prioritize_online")]
    public bool PrioritizeOnline { get; set; } //From "metro" Cookie
    //[JsonProperty("metro")]
    //public string ShopSession { get; set; } //From "_shop_session" Cookie
    //[JsonProperty("time_zone")]
    //public TimeZoneInfo TimeZone { get; set; }

  }

This is where I'm setting the value

 protected virtual void MapTimeZoneFacet(JObject jsonObject)
    {
      Assert.ArgumentNotNull(jsonObject, "jsonObject");

      var olsonTimeZone = jsonObject["timeZone"].Value<string>();

      var windowsTimeZone = Helpers.Extensions.UserTimeZoneInfo.OlsonTimeZoneToTimeZoneInfo(olsonTimeZone);

    

      using (XConnectClient client = SitecoreXConnectClientConfiguration.GetClient())
      {
        Contact contact = null;
        try
        {
          contact = client.Get<Contact>(new IdentifiedContactReference(AssemblyFacetInformation.ContactReference, "**value**"), new ContactExecutionOptions(new ContactExpandOptions(AssemblyFacetInformation.ContactReference)));
          var assemblyFacetInformation = contact.GetFacet<AssemblyFacetInformation>(AssemblyFacetInformation.DefaultFacetKey);
        //  assemblyFacetInformation.TimeZone = windowsTimeZone;
          client.SetFacet(contact, AssemblyFacetInformation.Timezone, assemblyFacetInformation);
          client.Submit();
        }

        catch (Exception ex)
        {
          var test = jsonObject;
        }

      }

    }

Did I miss something or doing anything wrong?

2
  • If I remember correctly, in a standalone env, the JSON model was to be deployed under xConnect and processing instances also. Commented Dec 1, 2022 at 12:07
  • @NutsAndBolts Didn't get your point. Commented Dec 1, 2022 at 12:12

1 Answer 1

2

I think one step you have missed to deploy "Deploy custom Facet model to XDB".

To Deploy the custom facet model to XDB you need to serialize the collection model in which you defined your custom facet model. To serialize into JSON prefer Console application to generate the JSON file.

class Program
    {
        static void Main(string[] args)
        {
            var serlizableModel = XdbModelWriter.Serialize(CustomFacetCollectionModel.Model);
            File.WriteAllText(CustomFacetCollectionModel.Model.FullName + ".json", serlizableModel);
        }
    }

On execution of the console application, it will generate a JSON file. Copy that JSON file and paste to the below places for single instance:

x-connect root path > App_data/Models
x-connect root path > App_data/jobs/continuous/IndexWorker/App_data/Models

For scaled environment deploy json in below location:

All instances of xConnect Collection
All instances of xConnect Collection Search
xConnect Search Indexer
Marketing Automation Operations
Marketing Automation Engine
Content Delivery
Content Management
xDB Processing
1
  • 1
    Thanks for the answer! Commented Dec 1, 2022 at 12:58

Your Answer

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

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