We are having a requirement to capture details and update it to custom facet. Whenever there's an identifier (in my case it is,email address from session) it works as expected. I'm able to see the details captured in xDB and I'm also able to retrieve based on identifier. Using the below code. LoadContactReadOnly accepts both identifier and contact id as valid parameters.
ContactRepository contactRepo =
Sitecore.Configuration.Factory.CreateObject("tracking/contactRepository", true)as ContactRepository;
if (!string.IsNullOrEmpty(UserContext.Current.EmailAddress))
{
contact = contactRepo.LoadContactReadOnly(UserContext.Current.EmailAddress);
}
else
{
contact = contactRepo.LoadContactReadOnly(Tracker.Current.Session.Contact.ContactId);
}
But when the user is not authenticated (doesn't have email address in session) identifier is not available. Now if I try to retrieve the contact using context contact id I always get a null contact.
What is the effective way to retrieve contacts based on current contact ID? is it possible to get the contacts without identifier? just based on contact id?
I don't see any errors too. Since we are using Sitecore 8.2, update 7. I will not be able to use xConnect.