﻿#### 

The latest release of **Sitecore 9.0** finally includes xConnect, a very much anticipated API Framework that allows integrating contacts and their experience data from practically any third party data source. xConnect is a scalable service layer that sits between xDB and any client (including Sitecore roles like Delivery and Reporting) that wants to read, write or search contacts and interactions.

On top of outstanding [documentation](https://doc.sitecore.net/developers/xp/tracking-and-session/index.html "Sitecore 9 xConnect documentation") available for xConnect, Jason Wilkerson has already published a number of posts introducing some xConnect API features [https://citizensitecore.com/2017/10/17/introducing-xconnect-for-sitecore-9/](https://citizensitecore.com/2017/10/17/introducing-xconnect-for-sitecore-9/ "xConnect API features")

There is, however, at least one known issue that you will find very frustrating as soon as you submit your first interaction using xConnect API which is:

“**The Experience Profile currently only supports website visit interactions. As a result, if an interaction does not fully populate the facets required for a web visit, an error is displayed.**”

A full list of known issues can be found here: [https://kb.sitecore.net/articles/125044](https://kb.sitecore.net/articles/125044 "Profile error") 

The following image illustrates the error:

![Sitecore 9 experience profile hotfix](https://www.brimit.com/-/media/images/blog/sitecore-9-experience-profile-hotfix1.png?la=en&amp;hash=2527712BF5C7B9364B92FB5EEDF16785)

A quick search in Logs reveals the following error: 

*11936 17:40:25 ERROR Object reference not set to an instance of an object.Exception: System.NullReferenceExceptionMessage: Object reference not set to an instance of an object. Source: Sitecore.Cintelat Sitecore.Cintel.Reporting.ReportingServerDatasource.Visits.GetVisitsWithLocations.FillTableWithRow(DataTable rawTable, Interaction curInteraction, Int32 index)at  Sitecore.Cintel.Reporting.ReportingServerDatasource.Visits.GetVisitsWithLocations.GetTableFromContactXconnect(DataTable rawTable, Guid contactID, Nullable`1 interactionID)   at Sitecore.Cintel.Reporting.ReportingServerDatasource.Visits.GetVisitsWithLocations.Process(ReportProcessorArgs args)*

Decompiling Sitecore.Cintel assembly we can see the following method:

```
      
    private void FillTableWithRow(DataTable rawTable, Interaction curInteraction, int index = 1)
    {
      WebVisit webVisit = CollectionModel.WebVisit(curInteraction);
      IpInfo ipInfo = CollectionModel.IpInfo(curInteraction);
      int count = Enumerable.ToList<PageViewEvent>(Enumerable.OfType<PageViewEvent>((IEnumerable) curInteraction.Events)).Count;
      DataRow row = rawTable.NewRow();
      row["ContactId"] = (object) curInteraction.Contact.Id;
      row["_id"] = (object) curInteraction.Id;
      row["ChannelId"] = (object) curInteraction.ChannelId;
      row["StartDateTime"] = (object) curInteraction.StartDateTime;
      row["EndDateTime"] = (object) curInteraction.EndDateTime;
      row["AspNetSessionId"] = (object) Guid.Empty;
      if (curInteraction.CampaignId.HasValue)
        row["CampaignId"] = (object) curInteraction.CampaignId;
      row["ContactVisitIndex"] = (object) index;
      row["DeviceId"] = (object) curInteraction.DeviceProfile.Id;
      row["LocationId"] = (object) Guid.Empty;
      row["UserAgent"] = (object) curInteraction.UserAgent;
      row["SiteName"] = (object) webVisit.SiteName;
      row["Value"] = (object) curInteraction.EngagementValue;
      row["VisitPageCount"] = (object) count;
      row["Ip"] = (object) ipInfo.IpAddress.ToString();
      row["Keywords"] = (object) webVisit.SearchKeywords;
      if (!string.IsNullOrEmpty(webVisit.Referrer))
      {
        Uri uri = new Uri(webVisit.Referrer);
        row["ReferringSite"] = (object) uri.Host;
      }
      row["GeoData_BusinessName"] = (object) ipInfo.BusinessName;
      row["GeoData_City"] = (object) ipInfo.City;
      row["GeoData_Region"] = (object) ipInfo.Region;
      row["GeoData_Country"] = (object) ipInfo.Country;
      rawTable.Rows.Add(row);
    }
  
```

The method is used to copy each interaction coming from xConnect to DataRow. DataTable with all interactions will further be used to bind data in a number of Experience Profile views including **visits, latest statistics, visit summary**.

A quick look to the collection database (which is a SQL 2016 DB by default in Sitecore 9 XP0 deployment option), **InteractionFacets** and **Interactions** tables will indicate your newly created interaction lacks a number of interaction facets including **WebVisit**, **IpInfo** and an entity reference for **DeviceProfile**. **FillTableWithRow()** method will fail in a number of places with **NullReferenceException** if your interaction lacks such data. If your interaction comes from online visits, Sitecore (Sitecore.Analytics.Tracker) will take care of such Facets and you won’t face any issues in the Experience Profile. 

One solution could be to add missing data when you submit interaction to xConnect API. You can create new Device Profile entity and attach the missing facets:

```
      
https://www.brimit.com//Add Device profile
DeviceProfile newDeviceProfile = new DeviceProfile(Guid.NewGuid());
newDeviceProfile.LastKnownContact = existingContact;
client.AddDeviceProfile(newDeviceProfile);
interaction.DeviceProfile = newDeviceProfile;

https://www.brimit.com//Add fake Ip info
IpInfo fakeIpInfo = new IpInfo("127.0.0.1");
fakeIpInfo.BusinessName = "Home";
client.SetFacet<IpInfo>(interaction, IpInfo.DefaultFacetKey, fakeIpInfo);

https://www.brimit.com//Add fake webvisit
WebVisit fakeWebVisit = new WebVisit();
fakeWebVisit.SiteName = "Offline";
client.SetFacet<WebVisit>(interaction, WebVisit.DefaultFacetKey, fakeWebVisit);
  
```

Note that your interactions will be accompanied with fake/dirty Facets data and more importantly above code violates the purpose of **DeviceProfile** entity. I don’t recommend you to do so, unless you know the purpose very well or replace fake data with valid meanings.

Another solution is to override FillTableWithRow() method. Basically, we need to add a number of checks for null reference and bind column with DBNull if facets are missing. 

![Sitecore 9 experience profile hotfix 2](https://www.brimit.com/-/media/images/blog/sitecore-9-experience-profile-hotfix2.png?la=en&amp;hash=89928695191F73D9309104D40276D560)

Once your code is ready, you will need to patch Sitecore configuration to use your **GetVisitsWithLocations** class. Create a new patch file in /App\_Config/Inlcude with the following:

```
      
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <group groupName="ExperienceProfileContactViews">
        <pipelines>
          <visits>
            <processor type="Sitecore9.HotFixes.Processors.Profile.GetVisitsWithLocationsCustom, Sitecore9.HotFixes" patch:instead="*[@type='Sitecore.Cintel.Reporting.ReportingServerDatasource.Visits.GetVisitsWithLocations, Sitecore.Cintel']" />
          </visits>
        <! –Another 7 pipelines using the same processor-->
        </pipelines>
      </group>
    </pipelines>
  </sitecore>
</configuration>
  
```

Complete source code available for download on  [github](https://github.com/avershalovich/Sitecore9.HotFixes "Sitecore9 HotFixes github").

Sitecore will certainly get the current list of known issues fixed in the next Update.

Fly high with Sitecore! [Ask Brimit](https://www.brimit.com/contact-us "contact us") for boost.

##### Do you need help with your Sitecore project?

      ![](~/media/CD37043DFD1F491D8E92958A11959F75.ashx?la=en&amp;hash=D08B252DD3B41C09B588007541E5D22F)

   [VIEW SITECORE SERVICES](https://www.brimit.com/expertise/sitecore-cms)

###### Author

[!\[Alexei Vershalovich\](https://www.brimit.com/-/jssmedia/feature/blogs/authors/alexei-vershalovich-brimit---500.png?h=1098&amp;iar=0&amp;w=1042&amp;hash=7551A887E43E4DDE95E9C95102DBDF1B)
Alexei Vershalovich
Principal Consultant, digital experience and e-commerce](https://www.brimit.com/blog/author?authors=Alexei%20Vershalovich)

#### More on Sitecore

[!\[How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2024/vercel_cover-image.png)
#Guides#How-toDXPE-commerce
##### How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects
Optimize and accelerate the development and deployment of complex multisite Sitecore projects.
Alexei Vershalovich on July 17, 2024](https://www.brimit.com/blog/how-vercel-will-help-you-save-effort-when-deploying-sophisticated-sitecore-projects)

[!\[Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2023/sitecore-mentoring---cover-image.png)
#How-toDXP
##### Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story
How to participate in the Sitecore Mentor program and help younger colleagues jump-start a career in Sitecore development.
Sergey Baranov on October 2, 2023](https://www.brimit.com/blog/training-up-tomorrows-sitecore-mvps)

[!\[Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2022/headless/adobestock_456986731.jpg)
#How-toDXPE-commerce
##### Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)
Discover how a headless CMS can benefit organizations that use Sitecore.
Daniil Raschupkin, Palina Trokhautsava on September 15, 2022](https://www.brimit.com/blog/going-headless-part-2-when-a-headless-cms-is-your-best-bet-if-you-have-sitecore)

![](https://bat.bing.net/action/0?ti=187017043&amp;tm=gtm002&amp;Ver=2&amp;mid=4bc091bd-3bf5-4f23-9ec0-82a395f912ff&amp;bo=2&amp;gtm_tag_source=1&amp;pi=0&amp;lg=en-US&amp;sw=800&amp;sh=600&amp;sc=24&amp;nwd=1&amp;tl=Sitecore%209%20Experience%20Profile%20Workaround&amp;kw=Sitecore,%20Sitecore%209,%20Experience%20Profile,%20interaction,%20xConnect,%20Workaround,%20hotfix&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Fsitecore-9-experience-profile-workaround&amp;r=&amp;lt=306&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=548399)