Access content when listen the event "node.deleted"

Enonic version: 7.0.2
OS: Ubuntu 18.04

Is possible get the fields of content, after listen the event “node.deleted”?
I need access the “owner” field of content, after the content is deleted.
For example:

  type: 'node.*',
  localOnly: false,
  callback: function (event) {{
      repository: 'com.enonic.cms.default',
      branch: 'draft',
      user: {
        login: 'su',
        userStore: 'system'
      principals: ['role:system.admin'],
      attributes: {
        'ignorePublishTimes': true
    }, onCallback)

    function onCallback () {
      if (event.type === 'node.deleted') { (node) {
          const content = contentLib.get({ key: })
          // Here, the content is not found, because the content was deleted.

No, there’s no way to get properties of the content when the node is deleted.

I kindof solved this (in java) by listening to node.stateUpdated and there checking if state was ContentState.PENDING_DELETE, then adding node to a nodesPendingDeleteMap cache which could be retrieved after the node deletion is published. Delete also (at least before) sendt one delete event for draft and one for master, so in delete event for draft you might fetch the content from master. There might be a potential race condition in the latter scenario, and in the former one have to be aware of that deleting a content by right clicking it and selecting ‘delete immediately’ (or something), no stateUpdated event was sendt. The source is unfortunately not open because it has some customer specific logic, but let me know and I can share the relevant part with you.

1 Like