# Process initiate with values and how to access them in Human task

**URL:** <https://community.ofelia.com/t/process-initiate-with-values-and-how-to-access-them-in-human-task/10197>\
**Category:** Q&A\
**Created:** [29 May 2020 09:49 UTC](https://community.ofelia.com/t/process-initiate-with-values-and-how-to-access-them-in-human-task/10197 "2020-05-29T09:49:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.sulaiman78\_1417356](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@m.sulaiman78\_1417356](https://community.ofelia.com/u/m.sulaiman78_1417356)\
**Post date:** [29 May 2020 09:49 UTC](https://community.ofelia.com/t/process-initiate-with-values-and-how-to-access-them-in-human-task/10197/1 "2020-05-29T09:49:09Z")

</div>

Hi All,

I am trying to pass some values and start a process from a java app but not sure how do I access them in the form.

(To view the the image below, right click and choose open in a new tab)

\<p\>\<img alt="test" src="https://ibb.co/BTvQ5dP" style="width: 100px; height: 100px;" /\>\</p\>

Here is the java code:

HashMap\<String, String\> parameters = new HashMap\<String, String\>();  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;parameters.put("server.url", "http://localhost:8080");  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;parameters.put("application.name", "bonita");  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, parameters);  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// log in to the tenant to create a session  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;APISession apiSession = loginAPI.login("walter.bates", "xxx");  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Process API  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ProcessAPI processapi = TenantAPIAccessor.getProcessAPI(apiSession);  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;IdentityAPI identityAPI = TenantAPIAccessor.getIdentityAPI(apiSession);  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;User user = identityAPI.getUserByUserName("walter.bates");  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//Find the List of deployed processes  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;final SearchOptions searchOptions = new SearchOptionsBuilder(0, 100).sort(ProcessDeploymentInfoSearchDescriptor.DEPLOYMENT\_DATE, Order.DESC).done();  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;final SearchResult\<ProcessDeploymentInfo\> deploymentInfoResults = processapi.searchProcessDeploymentInfos(searchOptions);  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Map\<String, Serializable\> variables = new HashMap\<String, Serializable\>() ;  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; **variables.put("varA", "test");&nbsp;&nbsp; &nbsp;  
&nbsp; &nbsp; &nbsp; &nbsp; variables.put("varC", "testa");&nbsp;&nbsp;** &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;

try {  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;long processDefinitionId = processapi.getProcessDefinitionId("TestPool", "1.0");  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// ----- create list of operations -----  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;List\<Operation\> listOperations = new ArrayList\<\>();  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Map\<String, Serializable\> listVariablesSerializable = new HashMap\<\>();  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (String variableName : variables.keySet()) {  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Object value = variables.get(variableName);  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (value != null && value instanceof Serializable) {  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Serializable valueSerializable = (Serializable) value;  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;variableName = variableName.toLowerCase();  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Expression expr = new ExpressionBuilder().createExpression(variableName, variableName, value.getClass().getName(), ExpressionType.TYPE\_VARIABLE);  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Operation op = new OperationBuilder().createSetDataOperation(variableName, expr);  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;listOperations.add(op);  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;listVariablesSerializable.put(variableName, valueSerializable);  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// ----- start process instance -----  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;processapi.startProcess(processDefinitionId, listOperations, listVariablesSerializable);

&nbsp;

But I am not sure how to access variables, varA and varC in BPM flow, ie in Human task or is it even correct what I am doing. If not how can I access those variables in the human task form after I start the process from Java app

&nbsp;

(To view the the image below, right click and choose open in a new tab)

![]()\<p\>\<img alt="test" src="https://ibb.co/P6JHFcS" style="width: 100px; height: 100px;" /\>\</p\>

Appreciate any help.

Thanks

---

<div class="post-metadata">

**Author:** ![romain.bioteau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/romain.bioteau/32/720_2.png) [@romain.bioteau](https://community.ofelia.com/u/romain.bioteau)\
**Post date:** [30 May 2020 08:11 UTC](https://community.ofelia.com/t/process-initiate-with-values-and-how-to-access-them-in-human-task/10197/2 "2020-05-30T08:11:54Z")

</div>

You have to use the [case variable Rest API](https://documentation.bonitasoft.com/bonita/7.10/bpm-api#toc13):

Create an External API variable in your task form _varA_ with URL: _../API/bpm/caseVariable/{{task.caseId}}/varA_

Then you can bind _varA.value_ to an input field.

The task variable is auto generated when you create a form from the Studio (Go to the Execution \> Form property on a Task and click on the pen icon to create or edit a form for this task)

Depending on your use case we recommend using the BDM to design and store your data. Used with process and task contracts it is possible to generate a lot of boiler plate between the form and the process (Using the Add from data... in Contract section)

You can have a look to [this documentation article](https://documentation.bonitasoft.com/bonita/7.10/contracts-and-contexts) for more information on that topic.

HTH

Romain

---

<div class="post-metadata">

**Author:** ![m.sulaiman78\_1417356](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@m.sulaiman78\_1417356](https://community.ofelia.com/u/m.sulaiman78_1417356)\
**Post date:** [4 June 2020 08:30 UTC](https://community.ofelia.com/t/process-initiate-with-values-and-how-to-access-them-in-human-task/10197/3 "2020-06-04T08:30:40Z")

</div>

Thanks a lot Romain.

It worked&nbsp; &nbsp; ![laugh](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/1X/0524b91271d2e9cb3b328e6822d072e14fb86391.png "laugh")
