updateContact( )


Updates a contact's properties.

The updateContact() function returns a Promise that resolves when the specified contact's information is updated.

Note: This function replaces the deprecated wixCrmBackend.updateContact(). The deprecated function will continue to work, but it will not receive updates. To keep any existing code compatible with future changes, see the migration instructions.

Each time the contact is updated, revision increments by 1. The existing revision must be included when updating the contact. This ensures you're working with the latest contact information, and it prevents unintended overwrites.

Note: Only visitors with Manage Contacts permissions can update contacts. You can override the permissions by setting the suppressAuth option to true.

Method Declaration
Copy
function updateContact(
  identifiers: Identifiers,
  contactInfo: ContactInfo,
  options: Options,
): Promise<Contact>;
Method Parameters
identifiersIdentifiersRequired

Contact ID and revision number.


contactInfoContactInfoRequired

Contact info.


optionsOptions

Contact update options.

Returns
Return Type:Promise<Contact>
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { contacts } from "wix-crm-backend"; export const myUpdateContactFunction = webMethod(Permissions.Anyone, () => { const contactIdentifiers = { contactId: "0677ef55-cf20-4f68-989a-f31d3649eb72", revision: 6, }; const contactInfo = { name: { first: "Annie", last: "New Name", }, extendedFields: { "custom.event-we-met-at": "Cloud Computing MegaCon", }, }; const options = { allowDuplicates: false, suppressAuth: false, }; return contacts .updateContact(contactIdentifiers, contactInfo, options) .then((updatedContact) => { return updatedContact; }) .catch((error) => { console.error(error); }); }); /* Promise resolves to: * { * "_id": "0677ef55-cf20-4f68-989a-f31d3649eb72", * "_createdDate": "2021-03-31T20:24:48.393Z", * "_updatedDate": "2021-04-07T20:37:48.588Z", * "revision": 7, * "info": { * "name": { * "first": "Annie", * "last": "New Name" * }, * "extendedFields": { * "custom.event-we-met-at": "Cloud Computing MegaCon", * "contacts.displayByFirstName": "Annie New Name", * "contacts.displayByLastName": "New Name Annie" * } * }, * "lastActivity": { * "activityDate": "2021-03-31T20:24:48.393Z", * "activityType": "CONTACT_CREATED" * }, * "source": { * "appId": "manual", * "sourceType": "ADMIN" * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?