Skip to main content
Keywords Highlighted to make it more readable.
Source Link
Sumit Helaiya
  • 3.2k
  • 2
  • 12
  • 23

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

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

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

Source Link

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

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?