1

I am working on Sitecore 9.0.2 and created a custom Update contact logic where I am storing Firstname, email and Custom facet to xDB. This fails if the person filling the form is an existing user.

Log says:

2019-06-03 14:00:45.704 +10:00 [Error] Sitecore.XConnect.Operations.SetFacetOperation`1[Sitecore.XConnect.Facet]: Sitecore.XConnect.Operations.FacetOperationException: Operation #3, AlreadyExists, Contact {c536d93f-1dad-0000-0000-0592c2e3e51c}, RYIForm
2019-06-03 14:00:45.846 +10:00 [Error] ["XdbContextLoggingPlugin"] XdbContext Batch Execution Exception
Sitecore.XConnect.Operations.FacetOperationException: Operation #3, AlreadyExists, Contact {c536d93f-1dad-0000-0000-0592c2e3e51c}, RYIForm

I was getting this issue with two facets: PhoneNumbers and Customfacet when i added Phonenumber to ExpandOptions the error was resolved for phone numbers but it still persists for RYIForm. Code snippet below:

var expandOptions = new ContactExpandOptions(CollectionModel.FacetKeys.PersonalInformation, CollectionModel.FacetKeys.EmailAddressList, RYIFacets.DefaultFacetKey, "PhoneNumbers");

Thanks, Samridhi

4

You need to check first if the facet already exists, the code to get or create the RYIFacets facet could like this:

var contact = context.Contact;
var facet = contact.GetFacet<RYIFacets>(RYIFacets.DefaultFacetKey);

if (facet == null)
{
facet = new RYIFacets();
}

When working with a facet, not all data is always loaded, so check. See also https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/set-contact-facets.html and https://doc.sitecore.com/developers/90/sitecore-experience-platform/en/access-contact-and-interaction-data-from-activity-type.html

1
  • Thanks Jan, the above snippet resolved my issue. Jun 4 '19 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.