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