updatePolicy( )


Updates a policy.

The updatePolicy() function returns a Promise that resolves to the newly-updated policy.

Each time the policy is updated, revision increments by 1. The existing revision must be included when updating the policy. This ensures you're working with the latest policy and prevents unintended overwrites.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Events - all permissions
Manage Policies
Learn more about app permissions.
Method Declaration
Copy
function updatePolicy(
  _id: string,
  policy: UpdatePolicy,
  options: UpdatePolicyOptions,
): Promise<Policy>;
Method Parameters
_idstringRequired

Policy ID.


policyUpdatePolicyRequired

Policy to update.


optionsUpdatePolicyOptions
Returns
Return Type:Promise<Policy>
JavaScript
import { policies } from "wix-events.v2"; // define policy ID and policy object to update const id = "52f15c5c-ea06-44f4-866a-b1cfa6f4f790"; const policy = { name: "Terms and Conditions Event 1", body: "If the Event is rescheduled, changed, moved or cancelled the Organiser cannot be held responsible for any resulting costs you may incur for travel, accommodation and other related goods, services or compensation.", revision: "2", eventId: "3d3d5c04-ece0-45a8-85f0-11a58edaa192", }; // update policy async function elevatedUpdatePolicyFunction() { const elevatedUpdatePolicy = wixAuth.elevate(policies.updatePolicy); try { const result = await elevatedUpdatePolicy(id, policy); return result; } catch (error) { console.error(error); // Handle the error } } /* Returns a promise that resolves to the updated policy. { "_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790", "revision": "3", "_createdDate": "2023-03-07T14:15:44.312Z", "_updatedDate": "2023-03-07T14:51:52.994Z", "name": "Terms and Conditions Event 1", "body": "If the Event is rescheduled, changed, moved or cancelled the Organiser cannot be held responsible for any resulting costs you may incur for travel, accommodation and other related goods, services or compensation.", "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192" } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?