title: Insert value into Workflow Payload in Java
body: <p>Can you insert values into a workflow payload?</p>
  
  <p>Using OSGI bundle, I have created a Java process, and in it created a counter "idValue" which increments by one after every workflow. </p>
  
  <p>I then have the process attached to a workflow, and the workflow to start with a form.</p>
  
  <p>What I want to do is insert the idValue into the workflow payload, so every workflow has an unique idValue, and finally displaying the payload in the email template generated with each form submission.</p>
  
  <p>Below is my JAVA class to create the idValue. How can I insert it into the payload of a workflow?</p>
  
  <pre><code>public void execute(WorkItem workItem, WorkflowSession session, MetaDataMap metaDataMap)
          throws WorkflowException {
  
  
      log.info("OrderBrochureIdGen called");
      int setValue = 200000;
  
      try {
  
          log.info("Before getting item");
  
          Session jcrSession = session.getSession();
  
          Node root = session.getSession().getRootNode();
  
          if (jcrSession.nodeExists("/content/Brochure/BrochureID")) {
              Node idNode = (Node)session.getSession().getItem("/content/data/orderBrochure/brochureID");
  
              log.info("idNode name is " + idNode.getProperty("idValue").getLong());
  
              long newValue = idNode.getProperty("idValue").getLong() + 1;
  
              idNode.setProperty("idValue", newValue);
  
          }
          else {
              Node idNode = JcrUtil.createPath("/content/Brochure/BrochureID", "nt:unstructured", session.getSession());
              log.info("added idNode " + idNode.getName());       
              idNode.setProperty("idValue", setValue);
  
          }
  
          session.getSession().save();
  </code></pre>