Sitecore-Forms-Extensions
Sitecore-Forms-Extensions copied to clipboard
Sitecore.XConnect-Error when saving a contact to xDB
Hi - we notice that xconnect though a lot of exception like sample below , search shows it might be a know issue in xconnect and fixes are provided here https://kb.sitecore.net/articles/397292 , can you please let us know if we can proceed with the fix?
2020-06-15T17:38:06 PID[3520] Error Sitecore.XConnect.Operations.AddContactOperation: Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact 2020-06-15T17:38:06 PID[3520] Error Sitecore.XConnect.Operations.SetFacetOperation`1[Sitecore.XConnect.Facet]: Sitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Classification 2020-06-15T17:38:06 PID[3520] Error ["XdbContextLoggingPlugin"] XdbContext Batch Execution ExceptionSitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact 2020-06-15T17:38:06 PID[3520] Error ["XdbContextLoggingPlugin"] XdbContext Batch Execution ExceptionSitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Classification
we have submitted a ticket to sitecore about it and below was there replies
I have reviewed your custom code and found the possible culprit. You have a custom method that utilize the SetFacet() method and update facets for the contact which remains in the session (Feature.FormsExtensions.XDb.Repository.XDbContactRepository.UpdateContactFacet). There can be a situation when the contact hasn't been updated in the session after submitting. When the session ends Sitecore tries to save this contact one more time. As a result, the "AlreadyExists" exceptions are generated because the contact has been already saved to xDB.
Based on this, I suggest you reviewing your code and make sure that the contact is reloaded after submitting:
{
client.Submit();
// Remove contact data from shared session state - contact will be re-loaded // during subsequent request with updated facets manager.RemoveFromSession(Sitecore.Analytics.Tracker.Current.Contact.ContactId); Sitecore.Analytics.Tracker.Current.Session.Contact = manager.LoadContact(Sitecore.Analytics.Tracker.Current.Contact.ContactId);
}
Please consider reading the following article for more information regarding this:
https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/set-contact-facets-in-session.html
The method I have mentioned belongs to the Feature.FormsExtensions.dll assembly that is located in the bin folder of your CD server.
so am trying to validate with your the solution they provided
Hmn, can you help me the case/context in which this occurs?
When fields are stored into xDB via "StoreFieldBindingValues" class, you can see the method xDbService.ReloadContactDataIntoSession(); is called on line 56.
This should already take care of reloading the contact into the session.
Hi- @bartverdonck I am in track with the same issue and letting you know that this issue happens in scaled environment.
Hi - so basically we are using the extension for sending mails and recapture controls , the functionality provided are satisfied our need so we did not add any custom development , let me know how i can provide you with more information that can help.
i will reply back to Sitecore ticket with information you provided.
Thanks
I faced this issue too, I think there is a race condition if binding to both the Experience Profile value provider, as well as using Identify Contact save action. It seems to happen for contacts that already have the contact identifier saved, and then come back with a new anonymous session, and then submitting the form again.
Thanks for the info @markgibbons25 . I'll try reproducing.
@markgibbons25 I have tried to reproduce this following the scenario you provided. Unfortunatly, I had no succes in reproducing the error. (Tried with test https://cm.sfe.localhost/bugs/bug-89) Any suggestions?
Ok I'll try set up a test case
We are experiencing the same. Any news?
Still waiting on a reproducable scenario.
I Have a reproduceable scenario and trying everything but still the error remains same, opened a ticket with sitecore and they said you are using the 3rd party module so they cant help here. Please give me some suggestions on this -
[Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.FacetOperationException: Operation #1, ReferenceNotFound, Contact, Emails
If you have a reproducible scenario then please share it here.
On Fri, 12 Aug 2022, 11:34 pm nag-abhishek, @.***> wrote:
I Have a reproduceable scenario and trying everything but still the error remains same, opened a ticket with sitecore and they said you are using the 3rd party module so they cant help here. Please give me some suggestions on this -
[Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.EntityOperationException: Operation #0, AlreadyExists, Contact [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception Sitecore.XConnect.Operations.FacetOperationException: Operation #1 https://github.com/bartverdonck/Sitecore-Forms-Extensions/issues/1, ReferenceNotFound, Contact, Emails
— Reply to this email directly, view it on GitHub https://github.com/bartverdonck/Sitecore-Forms-Extensions/issues/89#issuecomment-1213115604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYQJ5URZKA4KXEBAWTU6F3VYZHGVANCNFSM4PXZEHMQ . You are receiving this because you were assigned.Message ID: @.***>
We are using the send email event and when this event is triggered there is a below exception, and this is working as expected before but the below exception comes without any changes made related to this
