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?
Solved! Go to Solution.
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.
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.
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.