# Handling Process Variables

**URL:** <https://community.ofelia.com/t/handling-process-variables/6102>\
**Category:** Q&A\
**Created:** [1 July 2015 20:20 UTC](https://community.ofelia.com/t/handling-process-variables/6102 "2015-07-01T20:20:00Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtdonovan](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mtdonovan](https://community.ofelia.com/u/mtdonovan)\
**Post date:** [1 July 2015 20:20 UTC](https://community.ofelia.com/t/handling-process-variables/6102/1 "2015-07-01T20:20:00Z")

</div>

Hello,

For the version of Bonita. How should I handle process variables now? The examples that I see online only focus on business variables.

Should I mainly only use business variables now for my applications? My v6.5 process uses mainly process variables not business variables and I’ve attached them to the form directly. How would I perform this in the new version? Or should I?

Thank you

---

<div class="post-metadata">

**Author:** ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)\
**Post date:** [2 July 2015 03:31 UTC](https://community.ofelia.com/t/handling-process-variables/6102/2 "2015-07-02T03:31:41Z")

</div>

For a full reading of Business vs Process data please see the following:

[Business data](http://documentation.bonitasoft.com/business-data-model)  
[Process data](http://documentation.bonitasoft.com/specify-data-process-definition)

But to answer your very specific question…

_You are recommended to use business data instead of process data for any data that has meaning outside of one single process. Process data are typically items of data which affect the path of the process, or are used at several steps of the process, but which become redundant, once the process instance has completed_

So for example a Purchase Order which can be used in several places in a business would be Business Data, whereas you might have a test = is PO value \> 10,000, returns a TRUE/FALSE to a boolean variable (PORequireAuthorization). It is this Boolean variable that is a process variable as it is not required anywhere else but this specific instance of the process case.

Hope that helps,  
regards

---

<div class="post-metadata">

**Author:** ![Pablo\_Alonso\_de\_Lina](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/pablo_alonso_de_lina/32/735_2.png) [@Pablo\_Alonso\_de\_Lina](https://community.ofelia.com/u/Pablo_Alonso_de_Lina)\
**Post date:** [2 July 2015 12:41 UTC](https://community.ofelia.com/t/handling-process-variables/6102/3 "2015-07-02T12:41:07Z")

</div>

Hello,

To access process variables from the UI designer, you should use the REST API ([http://documentation.bonitasoft.com/bpm-api-1#activityvariable](http://documentation.bonitasoft.com/bpm-api-1#activityvariable)), when you create a new data of type External API you have a guideline with the examplo as well.

Cheers

---

<div class="post-metadata">

**Author:** ![mtdonovan](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mtdonovan](https://community.ofelia.com/u/mtdonovan)\
**Post date:** [2 July 2015 16:02 UTC](https://community.ofelia.com/t/handling-process-variables/6102/4 "2015-07-02T16:02:37Z")

</div>

These are both great responses.

So, just to clarify, I’m building a person related process. I should build this within the business variables (or outside and import as a jar) and any decisions made within the process should be captured in process variables.

---

<div class="post-metadata">

**Author:** ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)\
**Post date:** [2 July 2015 19:34 UTC](https://community.ofelia.com/t/handling-process-variables/6102/5 "2015-07-02T19:34:49Z")

</div>

You have to put this in context.

My way of thinking is…and others can pitch in because I don’t have the full answer…

Business Data (Variables) would be, in this case:

table 1: Personnel Table (in database)

columns are

firstName  
surname  
addressLine01  
addressLine02  
addressLine03  
position  
grade  
yearOfStarting

table 2: Benefits Table (in database)

columns are

grade  
benefit

the business logic would be something like this

Form 1: select person  
Form 2: current benefits  
gateway  
Form 3: (OPTIONAL) benefits to be assigned  
Form 4: (OPTIONAL) no benefits to be assigned  
And here is the important bit…

Between form 2 and 3 there is a piece of code that computes lengthOfService (a process variable) and the gateway says if lengthOfService \> 50 then go to form 3 otherwise show form 4.

The business data (variables) is essentially static here (can be updated though), but the lengthOfService (a process variable) is computed every time the process executes…

So for one individual the on day 49 years 11 months and 31 days he will be on grade A, but on 50 years and above he will be on grade B.

I hope this helps.

I will be writing a blog piece over the weekend about how to convert existing database tables into BDM without manually adding them by hand. This function does not exist within BonitaSoft today. The BDM could be quite large if considering all processes that could be developed.

regards

---

<div class="post-metadata">

**Author:** ![mtdonovan](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mtdonovan](https://community.ofelia.com/u/mtdonovan)\
**Post date:** [7 July 2015 13:35 UTC](https://community.ofelia.com/t/handling-process-variables/6102/6 "2015-07-07T13:35:57Z")

</div>

This is great. Thank you for the further detailed explanation.  
I’m trying to decide about comments. If the comments supports the gateway decision. Should I include this variable in the process variable or the business variable?

This would be an approval or disapproval decision then the user would enter the disapproval comments.

---

<div class="post-metadata">

**Author:** ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)\
**Post date:** [7 July 2015 14:03 UTC](https://community.ofelia.com/t/handling-process-variables/6102/7 "2015-07-07T14:03:16Z")

</div>

Before I answer, what is your answer to this question? You don’t actually say one way or the other and you don’t give a reason why you have chosen the one you have chosen…

🙂

Homework, my lad, it never goes away…

---

<div class="post-metadata">

**Author:** ![mtdonovan](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mtdonovan](https://community.ofelia.com/u/mtdonovan)\
**Post date:** [2 July 2015 16:06 UTC](https://community.ofelia.com/t/handling-process-variables/6102/8 "2015-07-02T16:06:36Z")

</div>

First does activityvariable == process variable?  
Also,  
How would I PUT the value from the form to the activity variable (process variable)? I just see the GET method.

---

<div class="post-metadata">

**Author:** ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)\
**Post date:** [2 July 2015 19:38 UTC](https://community.ofelia.com/t/handling-process-variables/6102/9 "2015-07-02T19:38:35Z")

</div>

Part 1, Yes av = pv UNLESS it is a transient variable which is not accessible.

Part 2, still working on that… 🙂 sorry…

---

<div class="post-metadata">

**Author:** ![mtdonovan](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mtdonovan](https://community.ofelia.com/u/mtdonovan)\
**Post date:** [16 July 2015 21:03 UTC](https://community.ofelia.com/t/handling-process-variables/6102/10 "2015-07-16T21:03:38Z")

</div>

I can’t seem to get this to work. I’m using the current taskId to try to pull my variable but it showing up empty

…/API/bpm/activityVariable/{{taskId}}/[variable\_name]

---

<div class="post-metadata">

**Author:** ![Quentin\_Choulet](https://avatars.discourse-cdn.com/v4/letter/q/3d9bf3/32.png) [@Quentin\_Choulet](https://community.ofelia.com/u/Quentin_Choulet)\
**Post date:** [17 July 2015 07:22 UTC](https://community.ofelia.com/t/handling-process-variables/6102/11 "2015-07-17T07:22:13Z")

</div>

Hi,

You have to use the activityId and not the taskId. So it would be something like :  
…/API/bpm/activityVariable/{{activityId}}/[variable\_name]

You can retrieve the activityId from the task object (caseId property). You can get the task object from the task id by calling :  
…/API/bpm/humanTask/{{taskId}}

Now, how to put a value in a variable. First you need to define a contract in BonitaStudio. Basically, the contract defines what should be returned by the form. Then, in the UIDesigner you have to link the values from your form into the contract entries. This is done in the formOutput variable. Each property of the formOutput object will be mapped to the contract entry with the same name.

Cheers

---

<div class="post-metadata">

**Author:** ![mtdonovan](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mtdonovan](https://community.ofelia.com/u/mtdonovan)\
**Post date:** [17 July 2015 13:33 UTC](https://community.ofelia.com/t/handling-process-variables/6102/12 "2015-07-17T13:33:02Z")

</div>

I have this linked to the form. I thought I could just use URL parameter to get the value for caseId, but it’s not working. How do I get the caseId into variable?

`
activityId {"displayDescription":"","executedBySubstitute":"0","processId":"8435075298124187275","parentCaseId":"13003","state":"ready","rootContainerId":"13003","type":"USER_TASK","assigned_id":"201","assigned_date":"2015-07-17 08:27:59.074","id":"260006","executedBy":"0","caseId":"13003","priority":"normal","actorId":"1409","description":"","name":"Review and Submit","reached_state_date":"2015-07-17 08:27:53.616","rootCaseId":"13003","displayName":"Review and Submit","dueDate":"2015-07-17 09:27:53.349","last_update_date":"2015-07-17 08:27:53.616"} 
`

---

<div class="post-metadata">

**Author:** ![mtdonovan](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@mtdonovan](https://community.ofelia.com/u/mtdonovan)\
**Post date:** [17 July 2015 15:22 UTC](https://community.ofelia.com/t/handling-process-variables/6102/13 "2015-07-17T15:22:20Z")

</div>

Ok,

I added GUI variable called “activity” and then created “caseID” GUI variable with  
javascript expression

`
var result = $data.activity.caseId
    return result;
`

I should just be able to call a GET Rest call to get my process variable. Correct? I called  
…/API/bpm/caseVariable?p=0&c=10&f=case\_id={{caseID}} to get a list of variables. I see my process variables. Is there another way to return my variables without perform another javascript expression.
