Search.../

updateResource( )

Updates a resource.

Description

The updateResource() function returns a Promise that resolves when a resource is updated.

Use this function to update all bookings resource information except for the resource's schedule. To update a resource's schedule use updateResourceSchedule().

Notes:

  • When updating a resource you cannot change the system tags used by the Wix Bookings app. Tags used by the app have the values "business" and "staff".
  • Only users with the Bookings Admin role can update a resource. You can override the role permissions by setting the options.suppressAuth parameter to true.

Syntax

function updateResource(id: string, resourceInfo: UpdateResourceInfo, [options: Options]): Promise<Resource>

updateResource Parameters

NAME
TYPE
DESCRIPTION
id
string

ID of the resource to be updated.

resourceInfo
UpdateResourceInfo

Resource information to update.

options
Optional
Options

An object representing the available options for updating a resource.

Returns

Fulfilled - Updated resource

Return Type:

Promise<Resource>
NAME
TYPE
DESCRIPTION
_id
string

Resource ID.

name
string

Resource name.

email
string

Resource email address.

phone
string

Resource phone number.

description
string

Resource description.

tags
Array<string>

Resource tags. Tags are used to identify, group, and filter the different types of resources. For example, 'staff' or 'room'.

scheduleIds
Array<string>

List of IDs of schedules owned by this resource.

status
string

Resource status.

One of:

  • "CREATED" Default status.
  • "DELETED" The resource was deleted.
  • "UPDATED" The resource was updated.

Was this helpful?

Update a resource, changing its phone and email

Copy Code
1import { resources } from "wix-bookings-backend";
2
3export function myUpdateResource(resourceId) {
4
5 const newPhone = "7778521";
6 const newEmail = "tomjones@yoga.com";
7 const options = { suppressAuth: true };
8
9 return resources.updateResource(resourceId, { phone: newPhone ,email: newEmail}, options)
10 .then((updatedResource) => {
11 return updatedResource;
12 }).catch((error) => {
13 console.error('Failed to update resource: ', error);
14 return error;
15 });
16}
17
18
19 /* Updated resource:
20 *
21 * {
22 * "_id": "dc19d7db-6996-494b-8d6d-943d64e1f32a",
23 * "name": "Tom Jones",
24 * "email": "tomjones@yoga.com",
25 * "phone": "7778521",
26 * "description": "Yoga and self-defense instructor.",
27 * "tags": [
28 * "staff"
29 * ],
30 * "scheduleIds": [
31 * "8fbeefbb-76dc-4f67-b292-66e871d5984a"
32 * ],
33 * "status": "UPDATED"
34 * }
35 */