CorvidReference

workflows

The wix-crm-backend module contains functionality for working with your site's workflows from backend code.

A workflow consists of a number of phases, also known as steps. The final phase in the workflow, the phase that indicates the workflow has been completed, is know as the win phase. Each phase can contain cards that move between the phases, indicating the card's progression through the workflow.

To use the Workflows API, import wixCrm from the wix-crm-backend module:

   import wixCrm from 'wix-crm-backend';

Table of Contents

FUNCTIONS

?
Perform actions on an object.
archiveCard( )Archives a workflow card.
createCard( )Creates a new workflow card.
createPhase( )Creates a new workflow phase.
createWorkflow( )Creates a new workflow.
deleteCard( )Deletes a workflow card by ID.
deletePhase( )Deletes a workflow phase by ID.
deleteWorkflow( )Deletes a workflow by ID.
getCard( )Gets a workflow card by ID.
getPhaseInfo( )Gets a phase info by ID.
getWorkflowInfo( )Gets a workflow info by ID.
listCards( )Gets a list of a workflow's cards.
listPhasesInfo( )Gets a list of a workflow's phases.
listWorkflowsInfo( )Gets a list of the site's workflows info.
moveCard( )Moves a card to a new position within a workflow.
movePhase( )Moves a phase to a new position with a workflow.
restoreCard( )Restores an archived workflow card.
updateCardFields( )Updates an existing workflow card.
updatePhaseFields( )Updates an existing workflow phase.
updateWorkflowFields( )Updates an existing workflow.

OBJECTS

?
Objects used when setting, getting, or calling the properties and methods listed above.
CardAn object containing card information.
CardListAn object containing a list of cards and pagination info.
ListCardOptionsAn object contains ListCards request data.
ListOptionsAn object containing options used when requesting a list of workflows or phases.
MoveCardOptionsAn object containing information used when moving a card.
MovePhaseOptionsAn object containing information used when moving a phase.
OrderOptionsAn object containing sort order options.
PhaseAn object containing phase information.
PhaseListAn object containing a list of phases and pagination info.
WorkflowAn object contains workflow.
WorkflowInfoAn object containing information about a workflow.
WorkflowListAn object containing a list of workflows and pagination info.

archiveCard( )

Archives a workflow card.

Description

The archiveCard() function returns a Promise that resolves when the card has been archived.

Syntax

function archiveCard(id: string): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the card to archive.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the card has been archived.

Examples

Archive a card

import wixCrm from 'wix-crm-backend';

export function archiveCard(id){
  return wixCrm.workflows.archiveCard(id);
}

// Returns a promise that resolves to void.

createCard( )

Creates a new workflow card.

Description

The createCard() function returns a Promise that resolves to the created card's ID when the card is created in the specified workflow phase.

Pass a value for the position parameter to specify the newly created card's position within the specified phase. Positions are zero-based, meaning the first position is0. When omitted, the newly created card is added to the specified phase as the top card within the phase.

Syntax

function createCard(workflowId: string, phaseId: string, card: Card, [position: number]): Promise<string>
PARAMETERS
?
Values that you pass to a function.
workflowId
string
ID of the workflow to create the card in.
phaseId
string
ID of the phase to create the card in.
card
The data to use when creating the card.
position(Optional)
number
The created card's position within the workflow.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<string>
Fulfilled - ID of the newly created card.

Examples

Create a card

import wixCrm from 'wix-crm-backend';

export function createCard(workflowId, phaseId, contactId, position = undefined){
  return wixCrm.workflows.createCard(
    workflowId,
    phaseId,
    {
      "name": "Card Name",
      "contactId": contactId
    },
    position
  );
}

// Returns a promise that resolves to:
// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"

createPhase( )

Creates a new workflow phase.

Description

The createPhase() function returns a Promise that resolves to the created phase ID when the phase is created in the specified workflow.

Pass a value for the position parameter to specify the newly created phase's position within the specified workflow. Positions are zero-based, meaning the first position is 0. When omitted, the newly created phase is added as the last non-win phase.

Syntax

function createPhase(workflowId: string, phase: Phase, [position: number]): Promise<string>
PARAMETERS
?
Values that you pass to a function.
workflowId
string
ID of the workflow to add the new phase to.
phase
The data required for phase creation.
position(Optional)
number
The created phase's position within the workflow.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<string>
Fulfilled - ID of the newly created phase.

Examples

Create a phase

import wixCrm from 'wix-crm-backend';

export function createPhase(workflowId, position){
  return wixCrm.workflows.createPhase(
    workflowId,
    {
      "name": "Phase Name"
    },
    position
  );
}

// Returns a promise that resolves to:
// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"

createWorkflow( )

Creates a new workflow.

Description

The createWorkflow() function returns a Promise that resolves to the created workflow ID.

Syntax

function createWorkflow(workflowInfo: WorkflowInfo): Promise<string>
PARAMETERS
?
Values that you pass to a function.
workflowInfo
The information required for workflow creation.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<string>
Fulfilled - ID of the newly created workflow.

Examples

Create a new workflow

import wixCrm from 'wix-crm-backend';

export function createWorkflow(){
  return wixCrm.workflows.createWorkflow(
    {
      "name": "My Workflow",
      "description":"The best workflow!"
    }
  );
}

// Returns a promise that resolves to:
// "3c9683ea-f6cc-470b-b0d1-2eb6b8cea912"

deleteCard( )

Deletes a workflow card by ID.

Description

The deleteCard() function returns a Promise when the specified card has been deleted.

Syntax

function deleteCard(id: string): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the card to delete.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the card has been deleted.

Examples

Delete a card

import wixCrm from 'wix-crm-backend';

export function deleteCard(id){
  return wixCrm.workflows.deleteCard(id);
}

// Returns a promise that resolves to void.

deletePhase( )

Deletes a workflow phase by ID.

Description

The deletePhase() function returns a Promise when the specified phase has been deleted.

Syntax

function deletePhase(id: string): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the phase to delete.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the phase has been deleted.

Examples

Delete a phase

import wixCrm from 'wix-crm-backend';

export function deletePhase(id){
  return wixCrm.workflows.deletePhase(id);
}

// Returns a promise that resolves to void.

deleteWorkflow( )

Deletes a workflow by ID.

Description

The deleteWorkflow() function returns a Promise when the specified workflow has been deleted.

Syntax

function deleteWorkflow(id: string): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the workflow to delete.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the workflow has been deleted.

Examples

Delete a workflow

import wixCrm from 'wix-crm-backend';

export function deleteWorkflow(id){
  return wixCrm.workflows.deleteWorkflow(id);
}

// Returns a promise that resolves to void.

getCard( )

Gets a workflow card by ID.

Description

The getCard() function returns a Promise that resolves to the card with the specified ID.

Syntax

function getCard(id: string): Promise<Card>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the card to get.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<Card>
Fulfilled - The card with the given ID.

Examples

Get a card

import wixCrm from 'wix-crm-backend';

export function getCard(id){
  return wixCrm.workflows.getCard(id);
}

// Returns a promise that resolves to 
// {
//    "name": "Card Name",
//    "id": "63c83c38-f504-4eb8-a48c-1d77c436a678",
//    "contactId": "95bc7a80-5500-4445-9c90-adc0ff1b25ac",
//    "phaseId": "15bc7a80-5500-4445-9c90-adc0ff1b25ac",
//    "createdDate": "2019-05-05T12:23:43Z",
//    "updatedDate": "2019-05-05T12:23:43Z",
//    "source": "Inbox"
// }

getPhaseInfo( )

Gets a phase info by ID.

Description

The getPhaseInfo() function returns a Promise that resolves to the phase with the specified ID.

Syntax

function getPhaseInfo(id: string): Promise<Phase>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the phase to get.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<Phase>
Fulfilled - The phase with the specified ID.

Examples

Get a phase info

import wixCrm from 'wix-crm-backend';

export function getPhaseInfo(id){
  return wixCrm.workflows.getPhaseInfo(id);
}

// Returns a promise that resolves to:
// {
//    name: "Phase Name",
//    id: "66f6443c-884f-4b12-beae-ab864fb489db"
// }

getWorkflowInfo( )

Gets a workflow info by ID.

Description

The getWorkflowInfo() function returns a Promise that resolves to the workflow info with the specified ID.

Syntax

function getWorkflowInfo(id: string): Promise<WorkflowInfo>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the workflow to get.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<WorkflowInfo>
Fulfilled - The workflow with the specified ID.

Examples

Get a workflow

import wixCrm from 'wix-crm-backend';

export function getWorkflowInfo(id){
  return wixCrm.workflows.getWorkflowInfo(id);
}

/* Returns a promise that resolves to:
 *
 *  {
 *    "name": "My Workflow",
 *    "id": "27cb0001-a464-4e1b-91c2-83d666577b75",
 *    "createdDate": "2019-05-19T12:35:55.408Z",
 *    "description": "Workflow description"
 *  }
 */

listCards( )

Gets a list of a workflow's cards.

Description

The listCards() function returns a Promise that resolves to a list of the the specified workflow's cards.

Use the options parameter to specify which cards to retrieve and in which order to retrieve them. Cards can be sorted based on their "id", "name", "phaseId", "createdDate", "updatedDate", "source", and "position". If no limit parameter is passed, the first 50 cards are returned. Sort order defaults to by "phaseId" and then by "position" ascending.

Syntax

function listCards(workflowId: string, options: ListCardOptions): Promise<CardList>
PARAMETERS
?
Values that you pass to a function.
workflowId
string
ID of the workflow to retrieve cards from.
options
Options to use when getting the list of cards.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<CardList>
Fulfilled - List of retrieved cards.

Examples

Get a list of cards

import wixCrm from 'wix-crm-backend';

export function listCards(workflowId, phaseId){
  return wixCrm.workflows.listCards(
    workflowId,
    {
      "phaseId": phaseId, 
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
  });
}

/* Returns a promise that resolves to:
 *  {  
 *    "items": [  
 *      {  
 *        "createdDate": "2019-05-21T12:21:10Z",
 *        "updatedDate": "2019-05-21T12:21:10Z",
 *        "name": "This is a card",
 *        "id": "5ae263d5-0fdc-4378-9172-655d010cc6d1",
 *        "contactId": "c4d0545b-f748-4e1f-93fb-6d8609fb2fb4",
 *        "phaseId": "15bc7a80-5500-4445-9c90-adc0ff1b25ac",
 *        "source": "Inbox",
 *      },
 *      {  
 *        "createdDate": "2019-05-21T12:21:10Z",
 *        "updatedDate": "2019-05-21T12:21:10Z",
 *        "name": "This is another card",
 *        "id": "63d55ae2-9172-0fdc-4378-10cc6d1655d0",
 *        "contactId": "c4d0545b-f748-4e1f-93fb-6d8609fb2fb4",
 *        "phaseId": "25bc7a80-5500-4445-9c90-adc0ff1b25ac",
 *        "source": "Wix Forms",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

listPhasesInfo( )

Gets a list of a workflow's phases.

Description

The listPhasesInfo() function returns a Promise that resolves to a list containing information about the specified workflow's phases.

Use the options parameter to specify which phases to retrieve and in which order to retrieve them. Phases can be sorted based on their "id", "name", and "position". If no limit parameter is passed, the first 50 cards are returned. Sort order defaults to by "position" ascending.

Syntax

function listPhasesInfo(workflowId: string, options: ListOptions): Promise<PhaseList>
PARAMETERS
?
Values that you pass to a function.
workflowId
string
ID of the workflow to retrieve phases from.
options
Options to use when getting the list of phases.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<PhaseList>
Fulfilled - List of retrieved phases.

Examples

Get a list of phases info

import wixCrm from 'wix-crm-backend';

export function listPhasesInfo(workflowId){
  return wixCrm.workflows.listPhasesInfo(
    workflowId,
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *  {  
 *    "items": [ 
 *      {  
 *        "id": "b00831ee-cc5d-4447-81d7-2ca1828f07b2",
 *        "name": "To-do"
 *      },  
 *      {  
 *        "id": "4c866e9d-4189-4570-8595-af43a1ea615e",
 *        "name": "In Progress"
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

listWorkflowsInfo( )

Gets a list of the site's workflows info.

Description

The listWorkflowsInfo() function returns a Promise that resolves to a list containing information about the site's workflows.

Use the options parameter to specify which workflows to retrieve and in which order to retrieve them. Workflows can be sorted based on their "name". If no limit parameter is passed, the first 100 workflows are returned. Sort order defaults to by "name" ascending.

Syntax

function listWorkflowsInfo(options: ListOptions): Promise<WorkflowList>
PARAMETERS
?
Values that you pass to a function.
options
Options to use when getting the list of workflows.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<WorkflowList>
Fulfilled - List of retrieved workflow info.

Examples

Get a list of workflows info

import wixCrm from 'wix-crm-backend';

export function listWorkflowsInfo(){
  return wixCrm.workflows.listWorkflowsInfo(
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *
 *  {
 *    "items": [
 *      {
 *        "id": "f01971ac-5514-43b0-bf6c-dde93345e4e3",
 *        "name": "First Workflow",
 *        "description": "First workflow description.",
 *        "createdDate": "2019-03-25T12:19:28.952Z",
 *      },
 *      {
 *        "id": "d5a7848d-121b-4ee3-ab53-9ec6f4acaecc",
 *        "name": "Second Workflow",
 *        "description": "Second workflow description.",
 *        "createdDate": "2019-05-05T09:49:16.580Z",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

moveCard( )

Moves a card to a new position within a workflow.

Description

The moveCard() function returns a Promise when the specified card has been moved to the new position.

Use the options parameter to specify the phase and position within that phase to move the card to. Positions are zero-based, meaning the first position is 0.

Syntax

function moveCard(cardId: string, options: MoveCardOptions): Promise<void>
PARAMETERS
?
Values that you pass to a function.
cardId
string
ID of the card to move.
options
Information about where to move the card.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the card has moved.

Examples

Move a card

import wixCrm from 'wix-crm-backend';

export async function moveCard(cardId, phaseId){
  return await wixCrm.workflows.moveCard(
    cardId,
    {
      "newPhaseId": phaseId,
      "newPosition": 0
    }
  );
}

// Returns a promise that resolves to void.

movePhase( )

Moves a phase to a new position with a workflow.

Description

The movePhase() function returns a Promise when the specified phase has been moved to the new position.

Use the options parameter to specify the new phase position within the workflow. Any non-win phase can be moved to any non-win position. The win phase cannot be moved. Positions are zero-based, meaning the first position is 0.

Syntax

function movePhase(id: string, options: MovePhaseOptions): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the phase to move.
options
Information about where to move the phase.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the phase has moved.

Examples

Move a phase

import wixCrm from 'wix-crm-backend';

export async function movePhase(phaseId, workflowId){
  return await wixCrm.workflows.movePhase(
    phaseId,
    {
      "workflowId": workflowId,
      "newPosition": 0
    }
  );
}

// Returns a promise that resolves to void.

restoreCard( )

Restores an archived workflow card.

Description

The restoreCard() function returns a Promise that resolves when the archived card has been restored.

Syntax

function restoreCard(id: string, options: MoveCardOptions): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the card to restore.
options
Information about where to restore the card to.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the card has been restored.

Examples

Restore a card

import wixCrm from 'wix-crm-backend';

export async function restoreCard(cardId, phaseId){
  return await wixCrm.workflows.restoreCard(
    cardId,
    {
      "newPhaseId": phaseId,
      "newPosition": 0
    }
  );
}

// Returns a promise that resolves to void.

updateCardFields( )

Updates an existing workflow card.

Description

The updateCardFields() function returns a Promise that resolves when the card has been updated with the specified values.

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

Syntax

function updateCardFields(id: string, card: Card): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the card to update.
card
The information to update the card with.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the card has been updated.

Examples

Update a card

import wixCrm from 'wix-crm-backend';

export function updateCardFields(id){
  return wixCrm.workflows.updateCardFields(
    id, 
    {
      "name": "New Name"
    }
  );
}

// Returns a promise that resolves to void

updatePhaseFields( )

Updates an existing workflow phase.

Description

The updatePhaseFields() function returns a Promise that resolves when the phase has been updated with the specified values.

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

Syntax

function updatePhaseFields(id: string, phase: Phase): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the phase to update.
phase
The information to update the workflow phase with.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the phase has been updated.

Examples

Update a phase

import wixCrm from 'wix-crm-backend';

export function updatePhaseFields(id){
  return wixCrm.workflows.updatePhaseFields(
    id,
    {
      "name": "New Name"
    }
  );
}

// Returns a promise that resolves to void.

updateWorkflowFields( )

Updates an existing workflow.

Description

The updateWorkflowFields() function returns a Promise that resolves when the workflow has been updated with the specified values. may be ordered by the following fields: id, name, createdDate

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

Syntax

function updateWorkflowFields(id: string, workflowInfo: WorkflowInfo): Promise<void>
PARAMETERS
?
Values that you pass to a function.
id
string
ID of the workflow to update.
workflowInfo
The information to update the workflow with.
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the workflow has been updated.

Examples

Update a workflow

import wixCrm from 'wix-crm-backend';

export function updateWorkflowFields(id){
  return wixCrm.workflows.updateWorkflowFields(
    id,
    {
      "name": "New Name"
    }
  );
}

// Returns a promise that resolves to void.

Card

An object containing card information.

Syntax

type Card = {
  name: string
  id: string
  contactId: string
  createdDate: Date
  updatedDate: Date
  source: string
  phaseId: string
}
MEMBERS
?
The properties of an object.
name
string
Name of the card.
id
string
Unique card identifier.
contactId
string
ID of the contact associated with the card.
createdDate
Date
Date the card was created.
updatedDate
Date
Date the card was last updated.
source
string

Source that created the card.

One of:

  • "Contacts"
  • "Inbox"
  • "Invoices"
  • "Price Quotes"
  • "Wix Forms"
phaseId
string
ID of the phase which contains the card.

Examples

Gets a card

import wixCrm from 'wix-crm-backend';

export function getCard(id){
  return wixCrm.workflows.getCard(id);
}

// Returns a promise that resolves to 
// {
//    "name": "Card Name",
//    "id": "63c83c38-f504-4eb8-a48c-1d77c436a678",
//    "contactId": "95bc7a80-5500-4445-9c90-adc0ff1b25ac",
//    "phaseId": "15bc7a80-5500-4445-9c90-adc0ff1b25ac",
//    "createdDate": "2019-05-05T12:23:43Z",
//    "updatedDate": "2019-05-05T12:23:43Z",
//    "source": "Inbox"
// }

CardList

An object containing a list of cards and pagination info.

Syntax

type CardList = {
  items: Array<Card>
  length: number
  totalCount: number
  pageSize: number
  totalPages: number
  currentPage: number
}
MEMBERS
?
The properties of an object.
items
Array<Card>
List of cards matching the list options.
length
number
Number of items in the current results page.
totalCount
number
Total number of cards in the specified workflow and phase.
pageSize
number
Number of items returned per page with the current list options.
totalPages
number
Total number of results pages.
currentPage
number
Index of the current page. Indices are zero-based.

Examples

Get a list of cards

import wixCrm from 'wix-crm-backend';

export function listCards(workflowId, phaseId){
  return wixCrm.workflows.listCards(
    workflowId,
    {
      "phaseId": phaseId, 
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
  });
}

/* Returns a promise that resolves to:
 *  {  
 *    "items": [  
 *      {  
 *        "createdDate": "2019-05-21T12:21:10Z",
 *        "updatedDate": "2019-05-21T12:21:10Z",
 *        "name": "This is a card",
 *        "id": "5ae263d5-0fdc-4378-9172-655d010cc6d1",
 *        "contactId": "c4d0545b-f748-4e1f-93fb-6d8609fb2fb4",
 *        "phaseId": "15bc7a80-5500-4445-9c90-adc0ff1b25ac",
 *        "source": "Inbox",
 *      },
 *      {  
 *        "createdDate": "2019-05-21T12:21:10Z",
 *        "updatedDate": "2019-05-21T12:21:10Z",
 *        "name": "This is another card",
 *        "id": "63d55ae2-9172-0fdc-4378-10cc6d1655d0",
 *        "contactId": "c4d0545b-f748-4e1f-93fb-6d8609fb2fb4",
 *        "phaseId": "25bc7a80-5500-4445-9c90-adc0ff1b25ac",
 *        "source": "Wix Forms",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

ListCardOptions

An object contains ListCards request data.

Syntax

type ListCardOptions = {
  limit: number
  phaseId: string
  fetchOnlyArchived: boolean
  order: OrderOptions
  skip: number
}
MEMBERS
?
The properties of an object.
limit(Optional)
number
Maximum number of cards to retrieve. Defaults to 50.
phaseId(Optional)
string
ID of phase to retrieve cards from. If omitted, will retrieve cards from all phases. Not to be used with fetchOnlyArchived.
fetchOnlyArchived(Optional)
boolean
Whether to retrieve only archived cards. Not to be used with phaseId.
order(Optional)
Ordering options.
skip(Optional)
number
Number of cards to skip before the retrieved items. Defaults to 0.

Examples

Get a list of cards

import wixCrm from 'wix-crm-backend';

export function listCards(workflowId, phaseId){
  return wixCrm.workflows.listCards(
    workflowId,
    {
      "phaseId": phaseId, 
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
  });
}

/* Returns a promise that resolves to:
 *  {  
 *    "items": [  
 *      {  
 *        "createdDate": "2019-05-21T12:21:10Z",
 *        "updatedDate": "2019-05-21T12:21:10Z",
 *        "name": "This is a card",
 *        "id": "5ae263d5-0fdc-4378-9172-655d010cc6d1",
 *        "contactId": "c4d0545b-f748-4e1f-93fb-6d8609fb2fb4",
 *        "phaseId": "15bc7a80-5500-4445-9c90-adc0ff1b25ac",
 *        "source": "Inbox",
 *      },
 *      {  
 *        "createdDate": "2019-05-21T12:21:10Z",
 *        "updatedDate": "2019-05-21T12:21:10Z",
 *        "name": "This is another card",
 *        "id": "63d55ae2-9172-0fdc-4378-10cc6d1655d0",
 *        "contactId": "c4d0545b-f748-4e1f-93fb-6d8609fb2fb4",
 *        "phaseId": "25bc7a80-5500-4445-9c90-adc0ff1b25ac",
 *        "source": "Wix Forms",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

ListOptions

An object containing options used when requesting a list of workflows or phases.

Syntax

type ListOptions = {
  limit: number
  order: OrderOptions
  skip: number
}
MEMBERS
?
The properties of an object.
limit(Optional)
number
Maximum number of items to retrieve. Defaults to 50 for phases and 100 for workflows.
order(Optional)
Ordering options.
skip(Optional)
number
Number of items to skip before the retrieved items. Defaults to 0.

Examples

Get a list of phases

import wixCrm from 'wix-crm-backend';

export function listPhasesInfo(workflowId){
  return wixCrm.workflows.listPhasesInfo(
    workflowId,
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *  {  
 *    "items": [ 
 *      {  
 *        "id": "b00831ee-cc5d-4447-81d7-2ca1828f07b2",
 *        "name": "To-do"
 *      },  
 *      {  
 *        "id": "4c866e9d-4189-4570-8595-af43a1ea615e",
 *        "name": "In Progress"
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

Get a list of workflows

import wixCrm from 'wix-crm-backend';

export function listWorkflowsInfo(){
  return wixCrm.workflows.listWorkflowsInfo(
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *
 *  {
 *    "items": [
 *      {
 *        "id": "f01971ac-5514-43b0-bf6c-dde93345e4e3",
 *        "name": "First Workflow",
 *        "description": "First workflow description.",
 *        "createdDate": "2019-03-25T12:19:28.952Z",
 *      },
 *      {
 *        "id": "d5a7848d-121b-4ee3-ab53-9ec6f4acaecc",
 *        "name": "Second Workflow",
 *        "description": "Second workflow description.",
 *        "createdDate": "2019-05-05T09:49:16.580Z",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

MoveCardOptions

An object containing information used when moving a card.

Syntax

type MoveCardOptions = {
  newPhaseId: string
  newPosition: number
}
MEMBERS
?
The properties of an object.
newPhaseId(Optional)
string
ID of the phase to move the card to. If omitted, the card remains in the same phase.
newPosition(Optional)
number
Position within the phase to move the card to. If omitted, the card is moved to the top of the phase.

Examples

Move a card

import wixCrm from 'wix-crm-backend';

export async function moveCard(cardId, phaseId){
  return await wixCrm.workflows.moveCard(
    cardId,
    {
      "newPhaseId": phaseId,
      "newPosition": 0
    }
  );
}

// Returns a promise that resolves to void.

MovePhaseOptions

An object containing information used when moving a phase.

Syntax

type MovePhaseOptions = {
  workflowId: string
  newPosition: number
}
MEMBERS
?
The properties of an object.
workflowId
string
ID of the workflow to move the phase to.
newPosition
number
Position within the workflow to move the phase to.

Examples

Move a phase

import wixCrm from 'wix-crm-backend';

export async function movePhase(phaseId, workflowId){
  return await wixCrm.workflows.movePhase(
    phaseId,
    {
      "workflowId": workflowId,
      "newPosition": 0
    }
  );
}

// Returns a promise that resolves to void.

OrderOptions

An object containing sort order options.

Syntax

type OrderOptions = {
  sort: string
  field: string
}
MEMBERS
?
The properties of an object.
sort
string
Order of sort. Either "asc" or "desc" (defaults to "asc").
field
string
Field to sort on.

Phase

An object containing phase information.

Syntax

type Phase = {
  name: string
  id: string
}
MEMBERS
?
The properties of an object.
name
string
Name of the phase.
id
string
Unique phase identifier.

Examples

Gets a phase

import wixCrm from 'wix-crm-backend';

export function listPhasesInfo(workflowId){
  return wixCrm.workflows.listPhasesInfo(
    workflowId,
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *  {  
 *    "items": [ 
 *      {  
 *        "id": "b00831ee-cc5d-4447-81d7-2ca1828f07b2",
 *        "name": "To-do"
 *      },  
 *      {  
 *        "id": "4c866e9d-4189-4570-8595-af43a1ea615e",
 *        "name": "In Progress"
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

PhaseList

An object containing a list of phases and pagination info.

Syntax

type PhaseList = {
  items: Array<Phase>
  length: number
  totalCount: number
  pageSize: number
  totalPages: number
  currentPage: number
}
MEMBERS
?
The properties of an object.
items
Array<Phase>
List of phases matching the list options.
length
number
Number of items in the current results page.
totalCount
number
Total number of phases in the specified workflow.
pageSize
number
Number of items returned per page with the current list options.
totalPages
number
Total number of results pages.
currentPage
number
Index of the current page. Indices are zero-based.

Examples

Get a list of phases

import wixCrm from 'wix-crm-backend';

export function listPhasesInfo(workflowId){
  return wixCrm.workflows.listPhasesInfo(
    workflowId,
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *  {  
 *    "items": [ 
 *      {  
 *        "id": "b00831ee-cc5d-4447-81d7-2ca1828f07b2",
 *        "name": "To-do"
 *      },  
 *      {  
 *        "id": "4c866e9d-4189-4570-8595-af43a1ea615e",
 *        "name": "In Progress"
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

Workflow

An object contains workflow.

Syntax

type Workflow = {
  workflowInfo: WorkflowInfo
  winPhaseId: string
}
MEMBERS
?
The properties of an object.
workflowInfo
Workflow information.
winPhaseId
string
ID of the win phase.

Examples

Get a workflow

import wixCrm from 'wix-crm-backend';

export function listWorkflowsInfo(){
  return wixCrm.workflows.listWorkflowsInfo(
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *
 *  {
 *    "items": [
 *      {
 *        "id": "f01971ac-5514-43b0-bf6c-dde93345e4e3",
 *        "name": "First Workflow",
 *        "description": "First workflow description.",
 *        "createdDate": "2019-03-25T12:19:28.952Z",
 *      },
 *      {
 *        "id": "d5a7848d-121b-4ee3-ab53-9ec6f4acaecc",
 *        "name": "Second Workflow",
 *        "description": "Second workflow description.",
 *        "createdDate": "2019-05-05T09:49:16.580Z",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

WorkflowInfo

An object containing information about a workflow.

Syntax

type WorkflowInfo = {
  id: string
  name: string
  description: string
  createdDate: Date
}
MEMBERS
?
The properties of an object.
id
string
Unique workflow identifier.
name
string
Name of the workflow.
description(Optional)
string
Workflow description.
createdDate(Optional)
Date
Date the workflow was created.

Examples

Get a list of workflows

import wixCrm from 'wix-crm-backend';

export function listWorkflowsInfo(){
  return wixCrm.workflows.listWorkflowsInfo(
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *
 *  {
 *    "items": [
 *      {
 *        "id": "f01971ac-5514-43b0-bf6c-dde93345e4e3",
 *        "name": "First Workflow",
 *        "description": "First workflow description.",
 *        "createdDate": "2019-03-25T12:19:28.952Z",
 *      },
 *      {
 *        "id": "d5a7848d-121b-4ee3-ab53-9ec6f4acaecc",
 *        "name": "Second Workflow",
 *        "description": "Second workflow description.",
 *        "createdDate": "2019-05-05T09:49:16.580Z",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */

WorkflowList

An object containing a list of workflows and pagination info.

Syntax

type WorkflowList = {
  items: Array<WorkflowInfo>
  length: number
  totalCount: number
  pageSize: number
  totalPages: number
  currentPage: number
}
MEMBERS
?
The properties of an object.
items
List of workflows matching the list options.
length
number
Number of items in the current results page.
totalCount
number
Total number of workflows in the site.
pageSize
number
Number of items returned per page with the current list options.
totalPages
number
Total number of results pages.
currentPage
number
Index of the current page. Indices are zero-based.

Examples

Get a list of workflows

import wixCrm from 'wix-crm-backend';

export function listWorkflowsInfo(){
  return wixCrm.workflows.listWorkflowsInfo(
    {
      "limit": 2,
      "offset": 10,
      "order": [ {
        "field": "name",
        "sort": "asc"
      } ]
    }
  );
}

/* Returns a promise that resolves to:
 *
 *  {
 *    "items": [
 *      {
 *        "id": "f01971ac-5514-43b0-bf6c-dde93345e4e3",
 *        "name": "First Workflow",
 *        "description": "First workflow description.",
 *        "createdDate": "2019-03-25T12:19:28.952Z",
 *      },
 *      {
 *        "id": "d5a7848d-121b-4ee3-ab53-9ec6f4acaecc",
 *        "name": "Second Workflow",
 *        "description": "Second workflow description.",
 *        "createdDate": "2019-05-05T09:49:16.580Z",
 *      }
 *    ],
 *    "length": 2,
 *    "totalCount": 100,
 *    "pageSize": 2,
 *    "totalPages": 50,
 *    "currentPage": 5
 *  }
 */