cancel
Showing results for 
Search instead for 
Did you mean: 

Document UI Refresh after Task creation

SergioFerreira_
Confirmed Champ
Confirmed Champ

Hi

I have a custom Document. This Document has a custom Summary page. On the boton page area, we have to show the Document Tasks. I have created a button, this button has to start a Workflow. After push the button, I expect a new Task created for this Document.

The problem is the page refresh. The Workflow was correctly started, but the Task is not presented on the same Summary page. I have to logout and login again in the Nuxeo to see my Task.

My code is following:


public void startWorkflow() throws Exception {
      automationService = getAutomationService();
      DocumentModel doc = navigationContext.getCurrentDocument();
      OperationContext ctx = new OperationContext(coreSession);
      ctx.setInput(doc);
      Map props = new HashMap();
      automationService.run(ctx, "WF_MYWORKFLOW", props);

      doc.refresh();
      coreSession.save();

      //Here I am trying desperately to make a REFRESH
      DocumentModel documentParent = documentManager.getDocument(doc.getParentRef());
      Events.instance().raiseEvent(EventNames.DOCUMENT_CHANGED, documentParent);
      Events.instance().raiseEvent(EventNames.DOCUMENT_CHANGED, doc);
      Events.instance().raiseEvent(EventNames.DOCUMENT_CHILDREN_CHANGED, doc);
      doc.refresh(DocumentModel.REFRESH_ALL, null);
}

Another thing that I tried was to create a EventHandler (in Nuxeo Studio) triggered by any Document modification, as following:


1)Run Script ->
org.nuxeo.ecm.automation.jsf.OperationHelper.getWebActions().resetTabList();
org.nuxeo.ecm.automation.jsf.OperationHelper.getDocumentListManager().resetWorkingList(org.nuxeo.ecm.webapp.documentsLists.DocumentsListsManager.CURRENT_DOCUMENT_SELECTION);
org.nuxeo.ecm.automation.jsf.OperationHelper.getWebActions().resetCurrentTab();
org.nuxeo.ecm.automation.jsf.OperationHelper.getContentViewActions().resetAllContent();
org.nuxeo.ecm.automation.jsf.OperationHelper.getContentViewActions().resetAll();
org.nuxeo.ecm.automation.jsf.OperationHelper.getContentViewActions().refreshAndRewind("MissionsRootContent");

I'm not sure if there are another ways to do that and if this is a Nuxeo error, or not. Please, help me.

Thanks.

1 REPLY 1

SergioFerreira_
Confirmed Champ
Confirmed Champ

The solution was to raise an especific event: TaskEventNames.WORKFLOW_NEW_STARTED

I removed all events on my class "startWorkflow()" and added only the evente above.

I removed also the Nuxeo Studio Event Handler (Run Script).

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.