Search...
onLocationCreated( )
Developer Preview
Triggered when a location is created.
Syntax
function onLocationCreated(event: LocationCreated): void
onLocationCreated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
LocationCreated
Contains information about the created location and metadata for the event.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event that triggers when a location is created
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixLocations_onLocationCreated(event) {6 const createdTime = event.metadata.eventTime;78 console.log(`Location was created at ${createdTime}. Event details:`, event)9}1011/* Full event object:12 * {13 * "entity": {14 * "_id": "a636dae4-fdc9-4da8-9eef-7b0d23b34f22",15 * "address": {16 * "city": "São Paulo",17 * "country": "BR",18 * "formatted": "123 Avenida Paulista, São Paulo",19 * "location": {20 * "latitude": -23.561722,21 * "longitude": -46.65527522 * },23 * "postalCode": "01311-000"24 * "streetAddress": {25 * "apt": ""26 * "name": "Avenida Paulista",27 * "number": "123",28 * },29 * "subdivision": "BR-SP",30 * },31 * "archived": false,32 * "businessSchedule": {33 * "periods": [34 * {35 * "closeDay": "MONDAY",36 * "closeTime": "18:00",37 * "openDay": "MONDAY",38 * "openTime": "08:00"39 * },40 * {41 * "closeDay": "TUESDAY",42 * "closeTime": "18:00",43 * "openDay": "TUESDAY",44 * "openTime": "08:00"45 * },46 * {47 * "closeDay": "WEDNESDAY",48 * "closeTime": "18:00",49 * "openDay": "WEDNESDAY",50 * "openTime": "08:00"51 * },52 * {53 * "closeDay": "THURSDAY",54 * "closeTime": "18:00",55 * "openDay": "THURSDAY",56 * "openTime": "08:00"57 * },58 * {59 * "closeDay": "FRIDAY",60 * "closeTime": "18:00",61 * "openDay": "FRIDAY",62 * "openTime": "08:00"63 * }64 * ],65 * "specialHourPeriod": [66 * {67 * "comment": "Half price in the lead up to Christmas!",68 * "endDate": "2023-12-24T23:59:00Z",69 * "isClosed": false,70 * "startDate": "2023-12-01T00:00:00Z"71 * }72 * ]73 * },74 * "default": false,75 * "description": "Our location in São Paulo City Center!",76 * "email": "saopaulo@example.com",77 * "fax": "011-55-11-987654321",78 * "name": "São Paulo City Center Store",79 * "phone": "011 98765 4321",80 * "revision": "1",81 * "status": "ACTIVE",82 * "timeZone": "America/Sao_Paulo",83 * },84 * "metadata": {85 * "entityId": "a636dae4-fdc9-4da8-9eef-7b0d23b34f22",86 * "eventTime": "2023-11-13T08:22:25.392520Z",87 * "id": "a41b6434-982d-413d-8ce0-ac4dd8d3dc00",88 * "triggeredByAnonymizeRequest": false89 * }90 * }91 */