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

"Empty Document created" event fired twice (Nuxeo FT 10.2)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.2, 10.3
    • Fix Version/s: QualifiedToSchedule
    • Component/s: Automation

      Description

      Steps to reproduce:

       

      1) Create a schema called barcode:

      • barcodeID (String)

      2) Create a document type a called box:

      • Extends: collection
      • Associated schemas: barcode

       

      3) Create an automation chain called AC_Box_Barcode to initialize some properties of the document:

      • Fetch > Context.FetchDocument
      • Execution context > Context.SetVar
        • name: barcodeID
        • value: @{java.lang.String.format("%010d", java.lang.Integer.parseInt(Fn.getNextId("BoxBarCodeID") ) )}
      • Document > Document.Update
        • properties: dc:title=@ {Context["barcodeID"]} bc:barcodeID=@{Context["barcodeID"]}
        • save: false

       

      4) Create an Event handler definition:

      • Events: Empty document created
      • Event handler activation:
        • Current document has one of the types: box
        • Current document has facet: Any
        • Current document is: Regular Document
      • Event handler execution:
        • Select an existing automation chain: AC_Box_Barcode

      5) Deploy your changes

      6) Create a new document 

       

      The automation chain is called 2 times: 

      • When you click on the document type icon
      • When you click on the CREATE button

      So, the ID is incremented in 2 units instead 1 as is expected.

       

      NOTE: Nuxeo 10.2 used in this test

       

      NOTE 2: To see that the event is fired twice you can replace the automation chain call for this automation script called  AS_Box_Barcode which provides the same feature but adding some logs:

      function run(input, params) {
        
        Console.log("--- AS_Box_Barcode ");
        
        var id = Fn.getNextId("BarCodeId");
        
        Console.log("\t id:" + id);
        
        input = Document.Update(
          input, {
      	/*required:true - type: properties*/
            'properties': "dc:title=" + id + "\nbc:barcodeID=" + id ,
      	/*required:false - type: boolean*/
      	'save': false
          }
        );
      
        return input;
      }
        
      

      This is the logs when you create a new document (onlye one). You can see the automation script has been called twice:

      2019-01-16 10:09:55,742 WARN  [http-nio-0.0.0.0-8080-exec-13] [org.nuxeo.automation.scripting.helper.Console] [LOG] --- AS_Box_Barcode 
      2019-01-16 10:09:55,751 WARN  [http-nio-0.0.0.0-8080-exec-13] [org.nuxeo.automation.scripting.helper.Console] [LOG] 	 id:7
      2019-01-16 10:10:06,190 WARN  [http-nio-0.0.0.0-8080-exec-7] [org.nuxeo.automation.scripting.helper.Console] [LOG] --- AS_Box_Barcode 
      2019-01-16 10:10:06,199 WARN  [http-nio-0.0.0.0-8080-exec-7] [org.nuxeo.automation.scripting.helper.Console] [LOG] 	 id:8
      2019-01-16 10:12:14,438 INFO  [http-nio-0.0.0.0-8080-exec-15] [org.nuxeo.runtime.reload.ReloadComponent] Before updating Nuxeo server
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tdelanous Thomas Delanous
                Participants:
              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: