Access entries data from netlify CMS events

I’m trying to access to some entries from a netflify CMS event:

name: 'preUnpublish',
handler: ({ entry }) => {
    // I want to look for any entry that is pointing (via relation widget) 
    // to this "unpublishing" entry, it  would be something like (is just and hypothetical example): 

    let otherEntries = getEntriesByCollection('some-collection') // this should return an array
    let entriesPointingThisEntry = 
        otherEntries.filter(entry => 
            entry.relation_field.includes(entry.get('slug')) // the relationship would be done by entry slug

Is it possible to do something like that?, is there any function like getEntriesByCollection or similar that I can use on CMS events?

The reason for doing this is that I’d like to alert the user that he is deleting an entry wich is being pointed by another entry, so he can delete that reference an avoid errors.

Hi @pedro199288 and welcome to the community.
That functionality is not yet available, but you could open a feature request for it.

As a workaround you should be able to query the git repo directly via API (specific implementation depends on your backend).
The token for accessing the API is stored in local storage under the key netlify-cms-user

1 Like