I’m trying to access to some entries from a netflify CMS event:
CMS.registerEventListener({
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.