1. Extend Dynamics CRM Contact FacetΒΆ
The default contact facet used to store CRM data on an xDB contact does not have the ability to store any account information. However, you can extend the contact facet so that it can.
Note
You can also create an entirely new contact facet, if you prefer. But since only a single value is going to be stored, there is not much value in creating a new contact facet.
- In Visual Studio, create a new project:
Project template Class Library Name Examples.DynamicsCrm
- Add the following references to the project:
- Sitecore.Analytics.DynamicsCrm.dll
- Sitecore.Analytics.Model.dll
- Add the following interface:
using Sitecore.Analytics.DynamicsCrm.Models;
using System;
namespace Examples.DynamicsCrm.Models
{
public interface IDynamicsCrmContactDataEx : IDynamicsCrmContactData
{
Guid AccountId { get; set; }
}
}
- Add the following class:
using Sitecore.Analytics.DynamicsCrm.Models;
using System;
namespace Examples.DynamicsCrm.Models
{
public class DynamicsCrmContactDataEx : CrmContactData, IDynamicsCrmContactDataEx
{
public DynamicsCrmContactDataEx()
{
base.EnsureAttribute<Guid>(nameof(AccountId));
}
public Guid AccountId
{
get
{
return base.GetAttribute<Guid>(nameof(AccountId));
}
set
{
base.SetAttribute<Guid>(nameof(AccountId), value);
}
}
}
}