cancel
Showing results for 
Search instead for 
Did you mean: 

JSON construct for passing input parameters

k_kunti
Champ in-the-making
Champ in-the-making
Hi All

I am looking for JASON construct for passing input parameter to a process while instantiating a process…I have two input parameters:

"assignee_email" and "assignee" … how do I set these up…

Thank you
Krish
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
Check out http://activiti.org/userguide/index.html#N11AD9

To add parameters, you can do something like this:

Request: POST /process-instance



{
  "processDefinitionId":"financialReport:1",
  "assignee_email":"john@doe.com"
}

k_kunti
Champ in-the-making
Champ in-the-making
Hi frederik

Thank you; I tried the same but got the following exception:

I am using these properties in my HTML mail template and Java assignment class. I have attached the files along with this post.

Thanks again
Krish
——————-
File:BPMN.xml

<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="SimpleUserTask" name="SimpleUserTask">
<startEvent id="startevent5" name="Start">
</startEvent>

<userTask id="usertask2" name="User Task">

<extensionElements>
<activiti:taskListener event="create" class="com.test.poc.DynamicAssignment" />
</extensionElements>
</userTask>
<sequenceFlow id="flow10" name="" sourceRef="usertask2" targetRef="endevent5">
</sequenceFlow>
<serviceTask id="mailtask3" name="Mail Task" activiti:type="mail">
<extensionElements>
<activiti:field name="to" expression="${assignee_email}"/>
<activiti:field name="from" expression="kkrish@ty.com">
</activiti:field>
<activiti:field name="html">
<activiti:expression><![CDATA[ <html>
            <body>
              Hello  ${assignee},<br/><br/>
                
              A new order has been allocated to you <b>please view the same in your inbox</b>.<br/><br/>
                 
              Kind regards,<br/>
                 
              TheCompany.
            </body>
          </html>
]]></activiti:expression>
</activiti:field>
</extensionElements>
</serviceTask><sequenceFlow id="flow16" name="" sourceRef="startevent5" targetRef="mailtask3">
</sequenceFlow><sequenceFlow id="flow17" name="" sourceRef="mailtask3" targetRef="usertask2">
</sequenceFlow><endEvent id="endevent5" name="End">
</endEvent>
</process>
</definitions>

———————————————-

<Fault xmlns="http://localhost/activiti-rest/service/process-instance">
   <callstack>
      <e/>
      <e>org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'assignee_email'</e>
      <e>org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)</e>
      <e>org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)</e>
      <e>org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)</e>
      <e>org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)</e>
      <e>org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:44)</e>
      <e>org.activiti.engine.impl.bpmn.MailActivityBehavior.getStringFromField(MailActivityBehavior.java:191)</e>
      <e>org.activiti.engine.impl.bpmn.MailActivityBehavior.execute(MailActivityBehavior.java:41)</e>
      <e>org.activiti.engine.impl.bpmn.JavaDelegateDelegate.execute(JavaDelegateDelegate.java:39)</e>
      <e>org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)</e>
      <e>org.activiti.engine.impl.pvm.runtime.ExecutionImpl.performOperation(ExecutionImpl.java:521)</e>
      <e>org.activiti.engine.impl.pvm.runtime.ExecutionImpl.start(ExecutionImpl.java:362)</e>
      <e>org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:66)</e>
      <e>org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29)</e>
      <e>org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22)</e>
      <e>org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37)</e>
      <e>org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)</e>
      <e>org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:64)</e>
      <e>org.activiti.rest.api.process.ProcessInstancePost.executeWebScript(ProcessInstancePost.java:45)</e>
      <e>org.activiti.rest.util.ActivitiWebScript.executeImpl(ActivitiWebScript.java:76)</e>
      <e>org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)</e>
      <e>org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:69)</e>
      <e>org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)</e>
      <e>org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)</e>
      <e>org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)</e>
      <e>javax.servlet.http.HttpServlet.service(HttpServlet.java:717)</e>
      <e>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)</e>
      <e>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)</e>
      <e>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)</e>
      <e>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)</e>
      <e>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)</e>
      <e>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)</e>
      <e>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)</e>
      <e>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)</e>
      <e>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)</e>
      <e>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)</e>
      <e>org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)</e>
      <e>java.lang.Thread.run(Thread.java:662)</e>
      <e>org.activiti.engine.ActivitiException: Unknown property used in expression</e>
      <e>org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:46)</e>
      <e>org.springframework.extensions.webscripts.WebScriptException: 00060051 Wrapped Exception (with status template): Unknown property used in expression</e>
      <e>org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:742)</e>
   </callstack>
   <exception>org.springframework.extensions.webscripts.WebScriptException - 00060051 Wrapped Exception (with status template): Unknown property used in expression</exception>
   <message>00060051 Wrapped Exception (with status template): Unknown property used in expression</message>
   <server>Spring WebScripts - v1.0.0 (Release Candidate 2 660) schema 1,000</server>
   <status>
      <code>500</code>
      <description>An error inside the HTTP server which prevented it from fulfilling the request.</description>
      <name>Internal Error</name>
   </status>
   <time>Jan 6, 2011 3:59:39 PM</time>
</Fault>

frederikherema1
Star Contributor
Star Contributor
Hmmm…

Can you please try without the underscore? So use assigneeEmail instead of assignee_email as variable-name and let me know if that works… Got a fleeing the underscore is the cause (since _type and _required is processed by the webscript that starts the process-instance via REST).

k_kunti
Champ in-the-making
Champ in-the-making
Hi frederik

It worked… as stated by you the "_" was the issue  Smiley Wink

Thanks again

Krish

frederikherema1
Star Contributor
Star Contributor
Created an issue for this http://jira.codehaus.org/browse/ACT-493.