onPolicyCreated( )


A backend event that fires when a Policy is created.

The onPolicyCreated() event handler runs when a Policy is created in your site. The received PolicyCreated object contains information about the new policy.

Note: Backend events are not fired when previewing your site.

Method Declaration
Copy
function wixEvents_onPolicyCreated(event: PolicyCreated): void;
Method Parameters
eventPolicyCreated

Information about the created policy and onPolicyCreated event.

A backend event that occurs when a policy is created
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEvents_onPolicyCreated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; } /* Full policy object: { "metadata": { "id": "f3d62dd6-db0c-445a-9bd5-aa0e0e06cd44", "entityId": "370ee789-5a2d-4e48-b2cf-adaf8a54c52e", "eventTime": "2023-03-08T11:04:53.171829Z", "triggeredByAnonymizeRequest": false }, "entity": { "_id": "370ee789-5a2d-4e48-b2cf-adaf8a54c52e", "revision": "1", "_createdDate": "2023-03-08T11:04:53.166Z", "_updatedDate": "2023-03-08T11:04:53.166Z", "name": "Terms and Conditions Event 1", "body": "Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.", "eventId": "9d720f99-1b5a-4141-9877-d32985391e18" } } */
Errors

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

Did this help?