Search.../

deleteContact( )

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

Description

Deletes 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.deleteContact().

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

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

The deleteContact() function returns a Promise that resolves when the contact with the given ID is deleted.

Syntax

function deleteContact(contactId: string, options: DeleteOptions): Promise<void>

deleteContact Parameters

NAME
TYPE
DESCRIPTION
contactId
string

The ID of the contact to delete.

options
DeleteOptions

Options to use when deleting the contact.

Returns

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

Return Type:

Promise<void>

Was this helpful?

Delete a 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 deleteContact = webMethod(Permissions.Anyone, (contactId) => {
5 wixCrmBackend.deleteContact(contactId)
6 .then( () => {
7 // contact has been deleted
8 })
9 .catch( (err) => {
10 // there was an error deleting the contact
11 });
12});
Force the deletion of a 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 deleteContactForcefully = webMethod(Permissions.Anyone, (contactId) => {
5 const options = {
6 "deleteMembers": true
7 };
8
9 return wixCrmBackend.deleteContact(contactId, options)
10 .then( () => {
11 // contact has been deleted
12 })
13 .catch( (err) => {
14 // there was an error deleting the contact
15 });
16});