Search.../

updateContact( )

Deprecated. This function will continue to work, but a newer version is available at wix-crm-backend.contacts.updateContact().

Description

Updates an existing contact.

Migration Instructions

If this function is already in your code, it will continue to work. To stay compatible with future changes, migrate to wix-crm-backend.contacts.updatecontact().

To migrate to the new function:

  1. Add the new import statement:

    import { contacts } from 'wix-crm-backend'
    javascript | Copy Code
  2. If you plan to migrate all contact functions that use wixCrmBackend, remove the original import wixCrmBackend statement.

  3. Look for any code that uses wixCrmBackend.updateContact(), and replace it with contacts.updateContact(). Update your code to work with the new updateContact() call and response properties.

  4. Test your changes to make sure your code behaves as expected.

The updateContact() function returns a Promise that resolves when the contact with the specified ID has been updated.

Only the properties passed in the ContactInfo object will be updated. All other properties will remain the same.

Syntax

function updateContact(contactId: string, contactInfo: ContactInfo): Promise<void>

updateContact Parameters

NAME
TYPE
DESCRIPTION
contactId
string

The ID of the contact to update.

contactInfo
ContactInfo

The information to update.

Returns

Fulfilled - When the contact is updated. Rejected - Error message.

Return Type:

Promise<void>

Was this helpful?

Update an existing contact

This example uses a deprecated function.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import wixCrmBackend from 'wix-crm-backend';
3
4export const myBackendFunction = webMethod(Permissions.Anyone, (contactId, firstName, lastName, email, phone) => {
5 wixCrmBackend.updateContact(contactId, {
6 "firstName": firstName,
7 "lastName": lastName,
8 "emails": [email],
9 "phones": [phone]
10 } )
11 .then( () => {
12 // contact has been updated
13 } )
14 .catch( (err) => {
15 // there was an error updating the contact
16 } );
17});