Search.../

deletePolicy( )

Permanently deletes a policy.

Description

The deletePolicy() function returns a Promise that resolves when the specified policy is deleted.

Deleted policies are not returned by the getPolicy() or queryPolicies() functions.

Admin Method

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

Syntax

function deletePolicy(policyId: string): Promise<void>

deletePolicy Parameters

NAME
TYPE
DESCRIPTION
policyId
string

ID of the policy to delete.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Delete Policy (dashboard page code)

Copy Code
1import { policies } from 'wix-events.v2';
2
3//define policy ID
4const policyId = '0907cf78-5177-4482-a627-b17ef06badec';
5
6//delete policy
7function myDeletePolicyFunction(){
8 try {
9 return policies.deletePolicy(policyId);
10 }
11 catch (error) {
12 console.error(error);
13 // Handle the error
14 }
15 };
16
17// Returns void
18
Delete Policy (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { policies } from 'wix-events.v2';
3import * as wixAuth from 'wix-auth';
4
5//define policy ID
6const policyId = '0907cf78-5177-4482-a627-b17ef06badec';
7
8export const elevatedDeletePolicyFunction = webMethod(Permissions.Anyone, () => {
9 const elevatedDeletePolicy = wixAuth.elevate(policies.deletePolicy);
10 try {
11 return elevatedDeletePolicy(policyId);
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16});
17
18/* Promise resolves to void */
19