Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-21504

Context variable 'Event' not available in automation scripting context when triggered on event 'beforeDocumentModification', but it is in automation chain context

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.10, 8.10, 9.1-SNAPSHOT
    • Fix Version/s: 7.10-HF22, 8.10-HF01, 9.1
    • Component/s: Automation

      Description

      When an automation chain is triggered by an event handler on event beforeDocumentModification, a context variable named Event is injected in the automation context, but the context variable Event in an automation scripting is empty.

      How to reproduce:

      • create an event handler triggered by event before document modification
      • when it executes the following automation chain:
        - Context.FetchDocument
        - Log:
            level: warn
            message: "<SUPNXP-18961_printDocumentBeforeModification> Event: @{Event}"
            category: org.nuxeo
        - Log:
            level: warn
            message: "<SUPNXP-18961_printDocumentBeforeModification> document's title before modification: @{Event.context.getProperty(\"previousDocumentModel\").getPropertyValue('dc:title')}"
            category: org.nuxeo
        - Log:
            level: warn
            message: "<SUPNXP-18961_printDocumentBeforeModification> document's title after modification: @{Document['dc:title']}"
            category: org.nuxeo
        

        it generates the following logs:

        14:22:49,738 WARN  [nuxeo] <SUPNXP-18961_printDocumentBeforeModification> Event: org.nuxeo.ecm.core.event.impl.EventImpl@3f993666
        14:22:49,742 WARN  [nuxeo] <SUPNXP-18961_printDocumentBeforeModification> document's title before modification: BLANK.pdf
        14:22:49,742 WARN  [nuxeo] <SUPNXP-18961_printDocumentBeforeModification> document's title after modification: BLANK.pdf2
        14:22:49,794 WARN  [Console] <logDocumentModified> /default-domain/workspaces/ws1/BLANK.pdf
        
      • when it executes the following automation scripting:
        function run(input, params) {
          Console.warn('<SUPNXP18961_printDocumentBeforeModification> Event: ' + Event);
          Console.warn('<SUPNXP18961_printDocumentBeforeModification> Event: ' + JSON.stringify(Event)); // EMPTY object, WHY?
          Console.warn('<SUPNXP18961_printDocumentBeforeModification> Event.context: ' + Event.context);
        }
        

        it generates the following logs:

        14:28:06,176 WARN  [Console] <SUPNXP18961_printDocumentBeforeModification> Event: [object Object]
        14:28:06,176 WARN  [Console] <SUPNXP18961_printDocumentBeforeModification> Event: {}
        14:28:06,177 WARN  [Console] <SUPNXP18961_printDocumentBeforeModification> Event.context: undefined
        14:28:06,248 WARN  [Console] <logDocumentModified> /default-domain/workspaces/ws1/BLANK.pdf
        

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours
                6h