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 totrue
.
Syntax
function updateResource(id: string, resourceInfo: UpdateResourceInfo, [options: Options]): Promise<Resource>
updateResource Parameters
NAME
TYPE
DESCRIPTION
ID of the resource to be updated.
Resource information to update.
An object representing the available options for updating a resource.
Returns
Fulfilled - Updated resource
Return Type:
NAME
TYPE
DESCRIPTION
Resource ID.
Resource name.
Resource email address.
Resource phone number.
Resource description.
Resource tags. Tags are used to identify, group, and filter the different types of resources. For example, 'staff' or 'room'.
List of IDs of schedules owned by this resource.
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
1import { Permissions, webMethod } from "wix-web-module";2import { resources } from "wix-bookings-backend";34export const myUpdateResource = webMethod(Permissions.Anyone, async (resourceId) => {5 const newPhone = "7778521";6 const newEmail = "tomjones@yoga.com";7 const options = { suppressAuth: true };89 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});1718/* 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 */