AnsweredAssumed Answered

Execute workflow script through Web Service

Question asked by harishns on Nov 20, 2009
Hi,
I want to start advance workflow to the folder/document using web service,

My workflow script is as follows
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:parallelreview";
workflow.parameters.requiredApprovePercent = 20;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;
workflow.parameters["bpm:assignees"] =[ people.getPerson("admin")];
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);

The script will work fine

My web service client code is as follows
      try
      {
         AuthenticationUtils.startSession("admin", "admin");
         Query query = new Query(Constants.QUERY_LANG_LUCENE,
               "+@cm\\:name:\"jbpmworkflowinitiator.js\" +PATH:\"/app:company_home/cm:CLMSpace5/cm:Draft5/*\"");
         QueryResult queryResult = WebServiceFactory.getRepositoryService().query(STORE, query, false);
         if (queryResult.getResultSet().getTotalRowCount() > 0)
         {
            System.out.println("Reference : " + queryResult.getResultSet().getRows()[0].getNode().getId());
         }
         Reference scriptRef = new Reference(
               STORE,
               queryResult.getResultSet().getRows()[0].getNode().getId(),
               "/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/content/1.0}CLMSpace5/{http://www.alfresco.org/model/content/1.0}Draft5/{http://www.alfresco.org/model/content/1.0}jbpmworkflowinitiator.js");

         Query query1 = new Query(Constants.QUERY_LANG_LUCENE,
               "+@cm\\:name:\"AdvancedWorkflow_On_Space.doc\" +PATH:\"/app:company_home/cm:CLMSpace5/*\"");
         QueryResult query1Result = WebServiceFactory.getRepositoryService().query(STORE, query1, false);
         if (queryResult.getResultSet().getTotalRowCount() > 0)
         {
            System.out.println("Reference : " + query1Result.getResultSet().getRows()[0].getNode().getId());
         }

         Reference docref = new Reference(
               STORE,
               query1Result.getResultSet().getRows()[0].getNode().getId(),
               "/app:company_home/cm:CLMSpace5/cm:AdvancedWorkflow_On_Space.doc");

         String scriptResult = ActionUtils.executeScript(docref, scriptRef);
      } catch (Exception e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } finally
      {
         AuthenticationUtils.endSession();
      }
   }

when I execute this code, I am getting error
There is no conversion registered for the value: 
   value class: org.mozilla.javascript.Undefined
   to class: java.lang.String
   value: org.mozilla.javascript.Undefined@3a95ff
I don't understand why is it referring mozilla equivalent of java String.
Please any body help me to resolve this issue.
Thank in advance

Outcomes