I have a
Sitecore 9 form where a user submits a form and that contact will be saved in
xDB. At the time of submitting I am checking in
xDB is duplicate contact exist, on basis of First name, Last name, Email and Identifier source.
I am able to get duplicate contact using the below query:
IAsyncQueryable<XConnect.Contact> query = client.Contacts .Where(c => c.Identifiers.Any(i => i.Source == "XYZ") && c.GetFacet<EmailAddressList>(EmailAddressList.DefaultFacetKey).PreferredEmail.SmtpAddress == emailID && c.GetFacet<PersonalInformation>(PersonalInformation.DefaultFacetKey).FirstName == firstname && c.GetFacet<PersonalInformation>(PersonalInformation.DefaultFacetKey).LastName == lastname ). WithExpandOptions(new ContactExpandOptions( PersonalInformation.DefaultFacetKey, EmailAddressList.DefaultFacetKey));
- Anonymous user is coming in the website and interact with the page and trigger some
- Anonymous has a contact ID
- Then user visits my form which I am talking above, here they submit a form, now if a user is a duplicate I am updating facets.
- My facets are updated for an existing contact
- After 20 mins, when the session expires, it is creating anonymous contact as well in
xDBand also saving
Interactionfor anonymous user.
I want anonymous user should not create in
Interaction should save for existing contact only.
I have tried to use
LoadContact method but still, it is not working
manager.RemoveFromSession(CurrentTracker.Contact.ContactId); CurrentTracker.Session.Contact = manager.LoadContact(new Guid(existingContact.Id.ToString()));