- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 08:31 AM
Hi!
We have to save process instance variable which is enum. For example: workflow has variable general_status which contains one of values:
public enum IwGeneralStatus{ IN_WORK("InWork"), WAITING_FOR_APPROVAL("WaitingForApproval"), WAITING_FOR_PAYMENT("WaitingForPayment"), PAID("Paid"), COMPLETED("completed"); // ...}
We wanted to set one of this values via BPMN diagram when task being executed. So, we created a Service task which contains expression ${iwGeneralStatus.IN_WORK} and tried to save it to our general_status:
but got next exception:
org.activiti.engine.ActivitiException: Unknown property used in expression: ${iwGeneralStatus.IN_WORK}
Is there a way to save enum to process variable via diagram?
- Labels:
-
Alfresco Process Services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 05:22 AM
After long research I've found a way to put object value to process instance variable via Script task.
I used groovy scripting with following code:
import com.iw.rest.api.v1.groups.domain.IwGroup;IwGroup initiatorGroup = new IwGroup("IW_INITIATOR");IwGroup legalGroup = new IwGroup("IW_LEGAL");IwGroup projectManagerGroup = new IwGroup("IW_PM");IwGroup accountantGroup = new IwGroup("IW_ACCOUNTANT");List<IwGroup> groups = [ initiatorGroup, legalGroup, projectManagerGroup, accountantGroup]execution.setVariable("group_sequence", groups);
Same thing could be used for enums:
execution.setVariable("general_status", com.iw.rest.api.v1.workflows.domain.IwGeneralStatus.IN_WORK);
Keep in mind that if you use groovy language in script task than you have to set script format field to groovy.
Otherwise it won't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2017 05:22 AM
After long research I've found a way to put object value to process instance variable via Script task.
I used groovy scripting with following code:
import com.iw.rest.api.v1.groups.domain.IwGroup;IwGroup initiatorGroup = new IwGroup("IW_INITIATOR");IwGroup legalGroup = new IwGroup("IW_LEGAL");IwGroup projectManagerGroup = new IwGroup("IW_PM");IwGroup accountantGroup = new IwGroup("IW_ACCOUNTANT");List<IwGroup> groups = [ initiatorGroup, legalGroup, projectManagerGroup, accountantGroup]execution.setVariable("group_sequence", groups);
Same thing could be used for enums:
execution.setVariable("general_status", com.iw.rest.api.v1.workflows.domain.IwGeneralStatus.IN_WORK);
Keep in mind that if you use groovy language in script task than you have to set script format field to groovy.
Otherwise it won't work.
