Wednesday, June 27, 2012

BPM 11g - Validating Boolean DO in User Task Skip Condition

This may sound like a small thing but honestly speaking I had to try out multiple methods to get this working through XPath expression builder. Hence I thought of making note of this on my blog so it may help a needful soul :)

<Employee>
   <EmployeeName>John Smith</EmployeeName>
   <IsMarried>true</IsMarried>
   <IsContract>true</IsContract>
</Employee>

Use-Case: All employees who are 'Contract' should be reviewed by 'Group A' and 'Permanent' employees must go through an additional level of review by 'Group B'.

Solution: The most logical way to build/represent this use-case in BPM 11g would be to create a user task with two sequential approval/review stages where the first stage participants would be 'Group A' and the sequential stage would be attended by 'Group B'. Now, by leveraging the 'Skip Condition' capability we can build a condition on 'Stage 2' to validate whether the boolean data object (in this case 'IsContract' element) is false. This means that if the <IsContract> element is true it skips the second stage of review else it goes through the second level of review.



Let's say the boolean data objects are modelled as 'Check Boxes' in ADF - where it returns 'true' when checked or 'false' when not checked by the user

Now, the problem is how to evaluate the boolean data object in Skip condition. Here is one way to evaluate boolean data objects;

xp20:matches(string(/task:task/task:payload/Employee/IsContract), '\s*(?i:true|1)\s*')='true'

What we are doing here is that converting the boolean data type into String and matching the result against the string 'true' or 'false'. Apparently we have to do this because, the direct boolean validation [/task:task/task:payload/Employee/IsContract = true] doesn't work in Skip condition.

Hope this helps.


No comments:

Post a Comment