Creating task variables using java api

cancel
Showing results for 
Search instead for 
Did you mean: 
aabb_activiti
Member II

Creating task variables using java api

Dear all

Is it possible to add new task variables using java api? 

Ex : User task initially has 3 form properties , and using java api we use something like :

task.addFormProperty(Variable_Name , VAriable_Type ,Readable , writable , Required);

So is that possible?

Thanks

6 Replies
bhchemss
Established Member

Re: Creating task variables using java api

Hi,

It's possible to set Variables on task with Java API

taskService.setVariable(String taskId,String variableName,Object value)

Or Locally with :

setVariableLocal(String taskId,String variableName,Object value)

Activiti - Engine 5.22.0 API 


Hope this help



aabb_activiti
Member II

Re: Creating task variables using java api

Hello

Thanks for your reply . However this is not my problem . I want to add a form property to a user task or a process variable to a process programaticaly.

Is this possible?

thanks

bhchemss
Established Member

Re: Creating task variables using java api

Ah I see , 

I am afraid that you only can get the form properties defined in your XML with Java API !

aabb_activiti
Member II

Re: Creating task variables using java api

Yes , that is true. But there is an approach but i cant get the last step done:

1-Create a user task 

2- add your new form properties 

3- replace old user task with a new one

I can do 1 and 2 but iam not able to replace the old task with new one.

Do you have any idea?

bhchemss
Established Member

Re: Creating task variables using java api

can you explain more ! , what do you mean by replacing , is it completing the old task ? , the new task doesn't belong to any process , do you want to get the task form data of the old one and save it to the new one ?

aabb_activiti
Member II

Re: Creating task variables using java api

Ofcourse!! 

Please consider the following workflow:

example workflow

Assume that user2 UserTask have initially one formProperty. 

The number of form properties i need is dynamic and related to a given input.So, im trying to create new usertask (name: user3) and add as much form properties as i want .Finally i replace user2 with user3 .

I hope you can help