Search.../

getContactById( )

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

Description

Gets an existing contact by ID.

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.getContact().

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

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

The getContactById() function returns a Promise that resolves to a contact whose ID matches the given ID.

Syntax

function getContactById(contactId: string): Promise<ContactInfo>

getContactById Parameters

NAME
TYPE
DESCRIPTION
contactId
string

The ID of the contact to get.

Returns

Fulfilled - The given contact's information. Rejected - Error message.

Return Type:

Promise<ContactInfo>
NAME
TYPE
DESCRIPTION
firstName
string

Contact's first name.

lastName
string

Contact's last name.

picture
string

Contact's image source.

emails
Array<string>

List of contact's email addresses. When creating a contact, if no phone number is provided, at least one email address must be provided.

loginEmail
string

Email address the contact who is also a member uses to log into the system.

phones
Array<string>

List of contact's phone numbers. When creating a contact, if no email is provided, at least one phone number must be provided.

labels
Array<string>

List of contact's labels. Labels are used to organize contacts. When setting the labels property, you can only list labels that already exist in your site's Contacts List.

customFields
string | number | Date

Any number of custom fields. Custom fields are used to store additional information about your site's contacts. When setting a custom field, use key:value pairs, where the key matches the display names in your site's Contacts List. You can only set values for custom fields that already exist in the Contacts application.

Was this helpful?

Get a contact by ID

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) => {
5 return wixCrmBackend.getContactById(contactId);
6});