Skip to main content

Bridge.Envs

"Envs" holds information specific to the current holder of the appointment.

.get(key, [defaultValue])

Return the Env Variable belonging to key.

const firstName = Bridge.Envs.get("user", {});

// Or using a dotted path
const id = Bridge.Envs.get("user.id", null);

.getDict()

Gets the Envs data as an object, can be useful for debugging.

Example response:

{
user: {
id: 6,
first_name: "Ryan",
last_name: "Jones",
email: "ryan.jones@testemail.com",
profile: null
},
contacts: [
{
id: 31368,
email: "ryan.jones@testemail.com",
first_name: "Ryan",
last_name: "Jones",
phone: null,
profile: null
}
],
customer: {
id: 30638,
title: "Ryan Jones",
logo_128: "https://yourserver/media/CACHE/images/customer/fd01fa4e12334843ab8e20b1b24e8c6f/1cca45bf1cb231a55475c5b1a9a0a651.png",
logo_256: "https://yourserver/media/CACHE/images/customer/fd01fa4e12334843ab8e20b1b24e8c6f/4c4a25a259834d20afddef4fc5c54c26.png",
logo_512: "https://yourserver/media/CACHE/images/customer/fd01fa4e12334843ab8e20b1b24e8c6f/8b675edaca0150ff5b51d63dc32ca2aa.png",
logo_original: "https://yourserver/media/customer/fd01fa4e12334843ab8e20b1b24e8c6f.png",
primary_colour: "7b8db7",
profile: null
},
appointment: {
id: 1176,
begin: "2024-05-27T04:40:26.000000Z",
end: "2024-05-27T06:40:26.000000Z"
},
tenancy: {
id: "66d7572f-85f6-4552-879a-25cf05ae311f",
name: "__default_tenancy__",
brand_colour: "3c2e44",
logo_cropped: "https://yourserver/media/tenancy/b5e4f031820449c8bcff88008735784b.png",
logo_original: "https://yourserver/media/tenancy/9f9cadc45ec842a19e2ff73c2555a4e3.png",
logo_background_colour: "4e1111"
},
server: {
root_url: "https://yourserver",
api_root: "https://yourserver/api/",
api_resources: {
activities: "https://yourserver/api/activities/",
adjunctsections: "https://yourserver/api/adjunctsections/",
adjunctslides: "https://yourserver/api/adjunctslides/"
// ...snip
}
}
}

.match(selector, defaultValue)

Use a css-style selector to look into the Envs. If you use match as opposed to match_many, then you are indicating that you expect to get a single match result.

See jsonselect for the documentation on how these selectors work.

const firstName = Bridge.Envs.match(".user .first_name", "John");

.match_many(selector, defaultValue)

Use a css-style selector to look into the Envs. If you use match_many as opposed to match, then you are indicating that you expect to get one or more matches.