Is It Possible to Access Space-Level Metadata Using the Record Hook Plugin?
Last updated: April 21, 2025
It is! The Record Hook Plugin includes the event parameter which can be used to gather context about the current space, including the spaceId. This can be used with the API to gather space-level metadata.
Example:
listener.use(
recordHook("Employees", async (record, event) => {
//grab spaceId from the event context
const spaceId = event.context.spaceId;
//grab space information
const meta = await api.spaces.get(spaceId);
//set variable from metadata
const userId = meta.data.metadata.user;
//use variable in recordHook
setLastName(record, userId);
return record;
})
);