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:
Add the new import statement:
javascript | Copy Codeimport { contacts } from 'wix-crm-backend'If you plan to migrate all contact functions that use
wixCrmBackend
, remove the originalimport wixCrmBackend
statement.Look for any code that uses
wixCrmBackend.createContact()
, and replace it withcontacts.createContact()
. Update your code to work with the newcreateContact()
call and response properties.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
The information for the contact being created or updated.
Returns
Fulfilled - The ID of the new or updated contact. Rejected - Error message.
Return Type:
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.
1import wixCrmBackend from 'wix-crm-backend';23export function myBackendFunction(firstName, lastName, email, phone) {4 return wixCrmBackend.createContact({5 "firstName": firstName,6 "lastName": lastName,7 "emails": [email],8 "phones": [phone]9 })10 .then((result) => {11 const contactId = result;12 return contactId;13 });14}15