cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to make variables of processes configurable

thilka
Champ in-the-making
Champ in-the-making
Hello,

we use Activiti in our Product and we want to be able to declare properties in the process definition which can later be changed by the admin user using our UI.
Example: We have a simple process:

start  ->  Do something (Service Task) ->  Do something else (Service Task) ->  end

We want to be able to configure the property (what to do) on the process basis and reference the value in the Service tasks.
One solution would be to pass the variable as parameter when starting the process and reference it using ${what_to_do}. This would work, but the administrator deploying the process has no idea which properties are "mandatory" for this process. So we want to have some kind of definition on a process basis (which properties should be set), read out the information from the process definition when deploying the process, and then ask the admin user to set the "mandatory" properties.

I tried to use ioSpecification/dataInput, but it is not meant to be used like this, I guess. Then I tried to use <property …> but it seems that Activiti does not read out this value from the XML.
What can we do? We do not want to extend the schema. Is there a way to make it work using the default BPMN / Activiti features?

Thanks
Tobias
10 REPLIES 10

jbarrez
Star Contributor
Star Contributor
No, that feature is currently not in Activiti. But you are not the first to ask … so could you create a Jira with the feature request.

Also: can't you use a start form to provide the details? And have the form definition configurable by the admin? That way you can specify which variables are mandatory, etc.

thilka
Champ in-the-making
Champ in-the-making
Thanks for the reply.
The problem with your solution is that the mandatory fields have to be entered at runtime. But I want some mandatory configuration properties.
E.g. The process looks like this:
start  ->  go (direction)  ->  end

when uploading the process, I want the admin to decide, which direction to go to (left, right). We already have the ability to change the properties during configuration time (we added another abstraction layer), but there is no way to tell the admin what properties he has to set.

Additionally it would be nice to have some kind of "default configuration" of the direction, let's say direction=left, which makes the process definition look like this after uploading:
start  ->  go (left)  ->  end

Now the admin should still be able to change the direction of the process, going the other direction.
We solved this issue for regular tasks by using activiti:fields and overriding those properties using our own mechanism. But there is no such mechanism for Execution Listeners or for process-wide properties.

I hope I made myself clear.

Thanks.
Tobias

jbarrez
Star Contributor
Star Contributor
Then I still don't see why it can't be done with variables through a start form?

Ie when the process starts, let him fill in a form with properties like the direction. If provided, use those variables, else use a default value.

But I'm getting the feeling your use case is different, as I don't yet understand what an 'admin' means for you in this case.

thilka
Champ in-the-making
Champ in-the-making
Our use case is that the admin user is the one who configures the system to run on customer site. Once the admin finished his job and the configuration is done, the system goes live and the end user gets access to the system. The end user is the one who starts the process and fills out the start form. The data the end user enters does not decide the direction to go (to keep to the example above) but who goes in the direction configured by the admin.
The main advantage of this approach is that we can define some kind of "process skeletons" where not everything is configured in the process xml file but can be configured during deployment time. Therefore we can use the same process (xml) to go left and right, and the one who deploys the process has to know that he has to configure the direction to go.
Maybe it helps to know that we are a product development company creating the (basic) functionality and the system is (almost always) adjusted to the customers environment/business processes. So we implement a process that can send you in different directions. But depending on where the system will be installed, the admin user can configure this process to go left for customer A and to go right for customer B.
Hope this helps understanding our use case better.

Tobias

frederikherema1
Star Contributor
Star Contributor
What about using services that expose that "admin configuration" in Activiti? You can lug in your own beans/services in activiti, so you can access them in, for example, expressions in a gateway. This way, you should have a sequence-flow condition like this:

<sequenceFlow sourceRef="decisionGateway" targetRef="pathA">
            <conditionExpression xsi:type="tFormalExpression">${adminService.getProperty('takePathA') == true}</conditionExpression>
</sequenceFlow>

thilka
Champ in-the-making
Champ in-the-making
Hello,

thanks for the reply. Interesting idea with the admin service. Will have to think about it. But the main issue for us is that we want to have one process defintion (in the simplest form like this: start->do something->end) where we already defined the "do something" part (e.g. change direction) and we want to have the admin user who deploys the process do define a parameter for the task (e.g. change direction to the left). And our application should tell the admin user that he has to fill out the parameter. Using the process variables would leave it to the admin to know he has to configure the parameter. Forgetting to configure this parameter would result in runtime errors (on customer site, maybe long after configuring the system).
Since we want to make it as easy as possible for the admin to configure valid processes, we are looking for a solution here.

I thought maybe BPMN has some features to support this (dataInput, properties) but Activiti hasn't implemented the support for these features yet.

Thanks
Tobias

frederikherema1
Star Contributor
Star Contributor
You can use a script-task, right after the start-event, which contains something like this:

<script>
    execution.setVariable("takePathA", true);
</script>

When deploying the process, the <script>..</script> can be altered, according to the admin-properties.

Another way is to use a service-task with http://activiti.org/userguide/index.html#serviceTaskFieldInjection

thilka
Champ in-the-making
Champ in-the-making
Hello,

yes, we already use script and service tasks this way. But both don't provide the functionality to tell the admin he has to set a specific property in order to make the whole process defintion work.

Tobias

frederikherema1
Star Contributor
Star Contributor
to tell the admin he has to set a specific property

This is exactly what the field-injection is for. Or do you mean a UI for this? Offcourse, a more "global" way of defining parameters for a process INSIDE the bpmn20.xml is currently not possible.

The only other thing I can think of is using an execution-listener (event=start) on the process and using field-injection on that one.
This allows configuring all sorts of params in one single place (in the beginning of the file) and have that execution-listener set variables accordingly, so the rest of the process behaves as expected…