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';23//define policy ID4const policyId = '0907cf78-5177-4482-a627-b17ef06badec';56//delete policy7function myDeletePolicyFunction(){8 try {9 return policies.deletePolicy(policyId);10 }11 catch (error) {12 console.error(error);13 // Handle the error14 }15 };1617// Returns void18
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';45//define policy ID6const policyId = '0907cf78-5177-4482-a627-b17ef06badec';78export 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 error15 }16});1718/* Promise resolves to void */19