In this post, will show you how to manipulate Custom attributes using BPM java API.
WFTASK table has the following columns along with columns used for public/private flex fields (Mapped attributes). Refer to this link for more information on mapped attributes.
CUSTOMATTRIBUTESTRING1 VARCHAR2(2000)
CUSTOMATTRIBUTESTRING2 VARCHAR2(2000)
CUSTOMATTRIBUTENUMBER1 NUMBER
CUSTOMATTRIBUTENUMBER2 NUMBER
CUSTOMATTRIBUTEDATE1 DATE
CUSTOMATTRIBUTEDATE2 DATE
BPM worklist also provides a search on these custom attributes as shown below. So when we are creating any custom worklist or in some other scenarios we can always populate these custom attributes using java apis.
public void updateCustomAttributes(String taskId, String customAttrStr1,String customAttrStr2) { IWorkflowContext wfCtx = null; try { //creating the customattrtype CustomAttributesType custAttrType = new ObjectFactory().createCustomAttributesType(); if(customAttrStr1 != null && !customAttrStr1.isEmpty()) { custAttrType.setCustomAttributeString1(customAttrStr1); } if(customAttrStr2 != null && !customAttrStr2.isEmpty()) { custAttrType.setCustomAttributeString2(customAttrStr2); } //get the admin workflow context wfCtx = getAdminWorkflowContext(); Task qryTask = getWfServiceClient().getTaskQueryService().getTaskDetailsById(wfCtx, taskId); qryTask.setCustomAttributes(custAttrType); getWfServiceClient().getTaskService().updateTask(wfCtx, qryTask); } catch (Exception ex) { System.out.println("in updateCustomAttributes exception"); ex.printStackTrace(); } }
To test this, send task id and values for custom attributes. We can use the following query to check the values.
select roottaskid, taskid, state,assignees,tasknumber,customattributestring1, customattributestring2
from wftask where roottaskid = ‘c1786a2b-f0a9-4058-aea2-43a0d40713eb’
Observations:
- We can update these attribute values by passing roottaskid also.
- When we update only one custom attribute its setting other values to null. To verify this, you can do first iteration by passing both attribute values and pass only one of these attribute values in second iteration of method calls.
- When custom attributes are set during human task creation using apis, same set of values will be copied to roottaskid and all child tasks.
Classic BPM is dead :-)) look at event driven architectures where you can do BPM on backend. UI itself is then nothing more than another scalable microservice in distributed eco-system.