Like what we’re doing? Star us on GitHub!

Access Globals within beforeDelete Hook

last month


Currently have a "working" beforeDelete hook which iterates over the Pages collection however I would also like to show a warning if a related topic is included within a global field..

collection: 'pages'

seems to be the line i need to change but I can't find any docs on how to access globals within the



Any help would be appreciated

export const checkTopicsNotInReleatedPagesOrSubNav: BeforeDeleteHook = async ({ req, id }) => {
    console.log('checkTopicsNotInReleatedPagesOrSubNav fired', id)

    console.log('req.payload:', req.payload)
    const result = await req.payload.find({
        collection: 'pages',
        limit: 100,
        depth: 2,
        where: {
            // 'globals.subNav.topic': { equals: id },
            'topics': { equals: id },
Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More