Search.../

createContact( )

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

Description

Creates a new contact or 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.createContact().

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.createContact(), and replace it with contacts.createContact(). Update your code to work with the new createContact() call and response properties.

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

The createContact() function returns a Promise that resolves to the newly created or updated contact's ID when the contact has been created or updated.

The passed ContactInfo object must contain at least one email address or phone number.

Syntax

function createContact(contactInfo: ContactInfo): Promise<string>

createContact Parameters

NAME
TYPE
DESCRIPTION
contactInfo
ContactInfo

The information for the contact being created or updated.

Returns

Fulfilled - The ID of the new or updated contact. Rejected - Error message.

Return Type:

Promise<string>

Was this helpful?

Create a new contact

This example uses a deprecated function.

This example contains a backend function that creates a new contact and returns the new contact's ID to the code that called the function.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import wixCrmBackend from 'wix-crm-backend';
3
4export const myBackendFunction = webMethod(Permissions.Anyone, async (firstName, lastName, email, phone) => {
5 return wixCrmBackend.createContact({
6 "firstName": firstName,
7 "lastName": lastName,
8 "emails": [email],
9 "phones": [phone]
10 })
11 .then((result) => {
12 const contactId = result;
13 return contactId;
14 });
15});