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

Task creation triggers the "documentCreated" core event too early

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.6.0-HF01, 5.7.1
    • Component/s: None

      Description

      The CreateTaskUnrestricted#createTask method creates the Task document in the session before having set its process id (= workflow id), and by the way other task properties such as name, type, creation date:

      DocumentModel taskDocument = session.createDocumentModel(parentPath, docName, taskDocumentType);
      taskDocument = session.createDocument(taskDocument);
      Task task = taskDocument.getAdapter(Task.class);
      if (task == null) {
      	throw new ClientRuntimeException("Document "
      	+ taskDocumentType
      	+ "  can not be adapted to a Task");
      }
      task.setName(taskName);
      task.setType(taskType);
      task.setProcessId(processId);
      task.setCreated(new Date());
      

      This is a problem because if you we have a listener on the documentCreated core event triggered by such a Task document creation, then it won't be aware of these Task properties.
      Typically we need to have the processId for instance to fecth the workflow input document.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h