xProfile (aka Sitecore Contact) is one of the most important in Sitecore Analytics that is used as “data input” for marketers who perform actions for marketing purposes and engaging customers.
In Sitecore, there are many built-in functions which support us to interact with Sitecore Contact and its information such as:
- Personal Information: Sitecore.XConnect.Collection.Model.PersonalInformation
- Email: Sitecore.XConnect.Collection.Model.EmailAddressList
- Address: Sitecore.XConnect.Collection.Model.AddressList
- Phone: Sitecore.XConnect.Collection.Model.PhoneNumberList
However, when creating Sitecore Contact, I faced an issue that some Contact information was not displayed in Sitecore Contact detail page even if I checked and saw that they were stored in the xDB actually as below:
Listing page showing the email:
But it was empty in detail page. Similar to the phone number and address.
The first thing I can think is possibly, I would need to rebuild the xDB index. However, after completed, the issue was still there.
The code didn’t have exception and I decided to go to xDB to check the data. Actually, the data is there:
Finally, I contacted Sitecore support team and after investigated, we found the root cause (Thank Sitecore support team so much). The problem is if
preferredKey in the constructors of xConnect Collection Models is null, the data won’t be shown up. The reason for this is the follow line:
var infoEmailLink = jsonData.preferredEmailAddress.Key ? jsonData.preferredEmailAddress.Value.SmtpAddress : "";
The corresponding JS file for the “Search/Contact” page in xProfile is “OverviewPanel.js” located under the: “\wwwroot\Your Sitecore \sitecore\shell\client\Applications\ExperienceProfile\Contact\OverviewPanel\” which would populate the relative values for the Name, Email, etc.
After set the preferredKey, the issue has been gone.
Thanks for reading and I hope its useful for you.
Happy Sitecore coding!