Search.../

updatePolicy( )

Developer Preview

Updates a policy.

Description

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.

This function is not a universal function and runs only on the backend.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function updatePolicy(_id: string, policy: UpdatePolicy): Promise<Policy>

updatePolicy Parameters

NAME
TYPE
DESCRIPTION
_id
string

Policy ID.

policy
UpdatePolicy

Policy to update.

Returns

The updated policy.

Return Type:

Promise<
Policy
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time when the policy was created.

_id
string

Policy ID.

_updatedDate
Date

Date and time of the policy's latest update in.

body
string

Policy body, usually containing various terms and conditions.

Min: 1 character

Max: 50000 characters.

Note: You can format text using various HTML tags such as <p>, <b>, <ul>, etc.

eventId
string

ID of the event to which the policy belongs.

name
string

Policy name that is visible in the dashboard and checkout form.

Min: 1 character

Max: 40 characters

revision
string

Revision number, which increments by 1 each time the policy is updated. The existing revision must be used when updating a policy to prevent conflicting changes. You'll get an error if you try to use the previous revision.

Was this helpful?

Update Policy

Copy Code
1import { policies } from 'wix-events.v2';
2
3// define policy ID and policy object to update
4const id = '52f15c5c-ea06-44f4-866a-b1cfa6f4f790';
5const policy = {
6 name: 'Terms and Conditions Event 1',
7 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.',
8 revision: '2',
9 eventId: '3d3d5c04-ece0-45a8-85f0-11a58edaa192'
10 };
11
12// update policy
13async function elevatedUpdatePolicyFunction(){
14 const elevatedUpdatePolicy = wixAuth.elevate(policies.updatePolicy);
15 try {
16 const result = await elevatedUpdatePolicy(id, policy);
17 return result;
18 }
19 catch (error) {
20 console.error(error);
21 // Handle the error
22 }
23 };
24
25/* Returns a promise that resolves to
26 the updated policy.
27{
28 "_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
29 "revision": "3",
30 "_createdDate": "2023-03-07T14:15:44.312Z",
31 "_updatedDate": "2023-03-07T14:51:52.994Z",
32 "name": "Terms and Conditions Event 1",
33 "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.",
34 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
35}
36*/