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

Fix execution of Automation scripting with parameters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.10
    • Fix Version/s: 8.10-HF33
    • Component/s: Automation
    • Release Notes Summary:
      The execution of Automation scripting uses the appropriate value of the provided parameters.
    • Tags:
    • Backlog priority:
      800
    • Sprint:
      nxfit 10.2.9
    • Story Points:
      3

      Description

      The parameters passed to an Automation Scripting seems to be cached, hence the second time the script is called, it used the previous values.

      Here is a scenario to reproduce the problem with the attached jar

      1. Navigate to the User workspace as Administrator
      2. Create a Folder named Folder
      3. Click on the New button
      4. Choose Note document type
      5. Observe that the title has the value "A Son of Folder"
      6. Navigate to the User workspace
      7. Click on the New button
      8. Choose Note document type
      9. Observe that the title still has the value "A Son of Folder"

      I've added some logging in the Automation Chain (ERROR level) and in the Automation script (WARN level) and I observe that:

      • the value read in the Automation chain is correct
      • the value read in the Automation script is incorrect the second time and seems to be read from a cache
      14:33:03,414 ERROR [logger] Parent = /default-domain/UserWorkspaces/Administrator
      14:33:07,147 WARN  [Console] parent path: /default-domain/UserWorkspaces/Administrator
      14:33:07,233 WARN  [Console] parent: DocumentModelImpl(c93b2809-58ef-4590-88bd-1662e60fcacf, path=/default-domain/UserWorkspaces/Administrator, title=c93b2809-58ef-4590-88bd-1662e60fcacf)
      
      14:33:21,745 ERROR [logger] Parent = /default-domain/UserWorkspaces/Administrator/Folder
      14:33:22,744 WARN  [Console] parent path: /default-domain/UserWorkspaces/Administrator
      14:33:22,780 WARN  [Console] parent: DocumentModelImpl(c93b2809-58ef-4590-88bd-1662e60fcacf, path=/default-domain/UserWorkspaces/Administrator, title=c93b2809-58ef-4590-88bd-1662e60fcacf)
      

      Code of the Automation Chain

      - Context.FetchDocument
      - Log:
          level: error
          message: "Parent = @{Event.context.getProperty('parentPath')}"
      - javascript.setDefault:
          parentPath: "@{Event.context.getProperty('parentPath')}"
      

      Code of the Automation Scripting

      function run(input, params) {
        var properties = {};
        Console.warn("parent path: " + params.parentPath);
        var parent = Repository.GetDocument(null, {"value": params.parentPath});
        Console.warn('parent: ' + parent);
        var title = parent.getPropertyValue("dc:title");
        properties["dc:title"] = "A Son of " + title;
        input = Document.Update(input, {
            'properties': properties,
            'save': false
        });
      
        return input;
      }
      

      The bug cannot be reproduced in 9.1 maybe a consequence of the work done by NXP-21294

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 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 - 1 day
                  1d