Kentico 13 - Update contact from user

Jason Howard asked on June 9, 2023 13:19

In the Aspx.Forms version of Kentico 12 when a user form was updated the relevant data in the contact record was updated based on the mappings defined in the 'On-line marketing' tab of the Membership > User class and then calling ContactInfoProvider.UpdateContactFromExternalData.

In Kentico 13 MVC no mapping takes place as when a user edits their profile that the controller updated the User record rather than relying on a Kentico form. Is there another method to sync the User data to the associated Contact data automatically or does that have to be done by updating the relevant Contact record fields in the controller when updating the User record maybe via ContactInfoProvider.UpdateContactFromExternalSource(..) and passing a dictionary of the items to update?

Correct Answer

Brenden Kehren answered on June 13, 2023 15:16

FYI:

  • Users are their own entity
  • Contacts are their own entity
  • Subscribers are contacts assigned to an email feed
  • Users are linked to a contact via the user's ID. (Contact.ContactUserID == User.UserID)

Your best bet is to create a global event handler against the user, whenever the user is updated perform an update on the contact.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on June 9, 2023 13:44

I don't believe updating the contact info when the related user record is updated is OOTB functionality. I'd look for a custom global event handler for this. I could be wrong.

0 votesVote for this answer Mark as a Correct answer

Jason Howard answered on June 13, 2023 14:59

Thanks Brendan, I'll probably go down that route and try and retrieve the field mappings that get defined in the 'On-line marketing' tab of the User object.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.