4 Replies Latest reply: Nov 6, 2013 6:25 AM by K VIKAS CHANDRAN RSS

    How to capture comments and read in next participent steps in Workflow?

    KaushikN Community Member

      I want to capture comments in one of the participent steps of my workflow and read them in the next step . Please share some suggestions on it .

      I have added a from step as the participent step but it is saving data with random ids . I am not able to figure out how to read the data for corresponding process step in the workflow ?

       

      Please help .

        • 1. Re: How to capture comments and read in next participent steps in Workflow?
          Sham HC Employee Hosts

          * explicitly setting the work items comment property

          workItem.getMetaDataMap().put("comment", "<Comment entered from user>");

           

          * If the previous step is process step then the comment will not be carried over so explicitly setting the work items comment property, by reusing the comment from the first participant found, when going up the history, Example:-

           

          var previousComment = "";

          var history = workflowSession.getHistory(workItem.getWorkflow());

          for (var index = history.size() - 1; index >= 0; index--) {

          var previous = history.get(index);

          var type = previous.getWorkItem().getNode().getType();

          if (type != null && (type.equals(Packages.com.day.cq.workflow.model.WorkflowNode.TYPE_PARTICIPANT) ||

          type.equals(Packages.com.day.cq.workflow.model.WorkflowNode.TYPE_DYNAMIC_PARTICIPANT))) {

          previousComment = previous.getWorkItem().getMetaDataMap().get("comment", Packages.java.lang.String);

          break;

          }

          }

          workItem.getMetaDataMap().put("comment", previousComment);

          • 2. Re: How to capture comments and read in next participent steps in Workflow?
            KaushikN Community Member

            Thanks a ton man . You are genious.

            • 3. Re: How to capture comments and read in next participent steps in Workflow?
              K VIKAS CHANDRAN Adobe Employee

              Thanks Sham appriciate it !

              This helped speed up, almost half a days effort saved.

              • 4. Re: How to capture comments and read in next participent steps in Workflow?
                K VIKAS CHANDRAN Adobe Employee

                had to write Java process for the same

                Just in case somebody wants a java version of the answer Sham mentioned above

                please feel free

                 

                HistoryItem previousHistoryItem;

                String stepType;

                 

                this.workItem = item;

                this.workflowSession = session;

                this.history = workflowSession.getHistory(workItem.getWorkflow());

                 

                Iterator<HistoryItem> historyIterator = history.iterator();

                 

                while(historyIterator.hasNext()){

                    previousHistoryItem = historyIterator.next();

                    stepType = previousHistoryItem.getWorkItem().getNode().getType();

                 

                    if(stepType != null && stepType.equals(WorkflowNode.TYPE_PARTICIPANT) && previousHistoryItem.getWorkItem().getMetaDataMap().get("someproperty",String.class) != null){

                        someproperty=previousHistoryItem.getWorkItem().getMetaDataMap().get("someproperty",String .class);

                        log("\n someproperty : " + "\n" + someproperty);

                    }else{

                        log("\nNo Step type or someproperty Found...");

                    }

                 

                }