02-22-2018 06:09 AM
Hello there,
Is there a possibility in Activiti to define certain Process Variables as Required in a Process Definition and request a list of those required variables from a Process Definition?
The Reason I'm asking is, I want to make some sort of Process Repository for Process selection.
Since my Processes more often than not need different variables or different numbers of variables, I want to show form that dynamically adjusts for how many / which variables are needed to my user.
Is there a functionality like that in Activiti or can someone recommend a solution?
thanks in advance
02-25-2018 03:12 AM
If your goal is only to define a list of variables used in the process in the process, I think that Data objects is optimal.
https://www.activiti.org/userguide/#dataobjects
And, you can get that list by the following code.
List<ValuedDataObject> dataObjects = repositoryService.getBpmnModel("processDefinitionId").getProcessById("processDefinitionKey").getDataObjects();
for(ValuedDataObject dataObject: dataObjects){
System.out.println(dataObject.getId());
System.out.println(dataObject.getName());
System.out.println(dataObject.getType());
} ad
02-22-2018 07:00 AM
Sounds like a use-case for start-forms with the forms set to have some required properties - I'd suggest to have a look at Activiti User Guide and see if it's a fit
02-22-2018 11:10 AM
I'd agree with you, but I have, and need to have my own Implementation of forms and not in java, so I cant really use those.
Thanks for the Idea though.
Are there any other possibilities ?
The main thing I need, is to just define required process variables and prompt them when looking up what process definitions I have in my repository.
Thanks in advance
02-23-2018 04:01 AM
Basically you want to store a list of the required process variables against each process definition. If that information will be in your forms then maybe you can find a way to get access to it from java or have the forms and the java get it from a common source. If it won't be in the forms or you can't get it then I guess basically you just need to capture it in a way the java can get it. If you've only a small amount of data then maybe you could put it in a properties file and check against it before you make the call to start a process. If it's more data then maybe a database table. I can't think of an Activiti-native way of doing this - probably because the Activiti way would be Activiti forms (but it's possible there is one and I'm missing it).
02-23-2018 04:06 AM
Okay thanks,
I'll think of something.
Shame that Activiti Process Definitions cant be prompted for something like that. Would be a really nice feature.
Thanks again for your help.
02-23-2018 04:26 AM
How about Data objects too?
02-23-2018 04:31 AM
Those look promising, question is though, can these be prompted? Via the Repositry Service for example? I.e can I look these up somehow? Didnt find anything in the userguide regarding that.
Thanks
02-23-2018 04:50 AM
List<ValuedDataObject> dataObjects = repositoryService.getBpmnModel("processDefinitionId").getProcessById("processDefinitionKey").getDataObjects();
for(ValuedDataObject dataObject: dataObjects){
System.out.println(dataObject.getId());
System.out.println(dataObject.getName());
System.out.println(dataObject.getType());
}
02-23-2018 04:32 AM
The main reason I don't think it's there is because Activiti/VariableInstance.xml at develop · Activiti/Activiti · GitHub doesn't feature any 'required' column/attribute. You should be able to find out which are the variables for the process definition in advance of starting it (Activiti/ProcessDefinitionEntityImpl.java at develop · Activiti/Activiti · GitHub ) by querying through repositoryService.createProcessDefinitionQuery. Without the 'required' attribute you won't have everything you want.
A hack might be to use some naming convention to capture which variables are required and which not.
We'd be open to discussing contributions (for which gitter.im/Activiti/Activiti7 is the best place). I can see the value in having that as an information-only field. I doubt we'd want the engine to enforce which variables are required or not as I think we'd want to leave that to the process implementation but we could talk more about that if you like.
02-23-2018 04:35 AM
Okay, thanks for the Input, both of you.
I'll try around with what Information you've given me and see if that gets me where I want to be 😃
Thanks again for your help.
Explore our Alfresco products with the links below. Use labels to filter content by product module.