Update OTB facets for anonymous user

36 views Asked by At

Using Sitecore 8.2, Im having trouble consistently update email, and name fields for a contact. In MongoDB, I've seen the contacts collection updated with these fields previously with this code but I've just removed all rows from Contacts in Mongo and executed the code below and there is no new entry in contacts

Tracker.Current.Session.Identify(emailAddress);
var currentContact = Tracker.Current.Contact;

var personalFacet = currentContact .GetFacet<Sitecore.Analytics.Model.Entities.IContactPersonalInfo>("Personal");

personalFacet.FirstName = firstName;

personalFacet.Surname = surName;

XdbContactManager.SaveAndReleaseContact(currentContact);
1

There are 1 answers

0
Steve Ward On

Replacing

XdbContactManager.SaveAndReleaseContact(currentContact);

with

XdbContactManager.FlushContactToXdb(currentContact);

Seems to have fixed my issue