As mentioned in my previous post, Oracle BPM 11g Quick Tip – Making BPM Process Instance Creation, this is another “Quick Tip” topic.  While on a project, I ran into an Oracle 10g SOA Suite guru and the topic came up about setting the value of the Composite Title or Name for an SOA Composite instance.  I applied the practice to a BPM 11g Composite with little issue.  Afterwards, I noticed that there are a few blog posts for setting the Title/Name in a BPEL process but not any for doing so in BPM.

Why set the Composite Title/Name from within a BPM Process? – In Oracle BPM 11g tracking instances via the Enterprise Manager (EM) console is a very important practice for troubleshooting and understanding what is going on in the BPM process.  Setting the composite Title/Name so that the BPM instance can be easily identified, searched, and accessed via the EM will help with any development or administrative tracking efforts.

In the following example I will demonstrate:

  • How to set the composite title/name from within a BPM process
  • The use of the XPath functions that are necessary for setting the title/name
  • The BPM instance being easily identified via the EM.

Example

  1. Create a new Async BPM process.
  2. Open the “Start” event and add an Input Argument of String type titled “orderIdArg”.

     

    Input Argument
  3. Create a Process Data Object of String type called “orderId”

     

    Process Data Object
  4. Now drop a script activity into the transition after the “Start” activity.  Name should be “Set Composite Title Name”.  Click OK.
  5. Double click the “Set Composite Title Name” script activity, and click the Implementation tab.  Check the “Associations” check box and click the “Edit Data Associations” pencil icon.

     

    Edit Data Associations
  6. Drag the “orderId” Process Data Object to the variable assignment area and then click the “Expression Builder” icon.

     

    Expression Builder
  7. In the “Expression Builder” : 1) Change the Mode to “XPath Exp.”, 2) In the “Advanced Functions” of the Functions list scroll down to find the “setCompositeInstanceTitle” function.  3) Select the “setCompositeInstanceTitle” function and click the “Insert Into Expression” button to add the function to the Expression area.  4) Select “orderId” from the Variables section and pass the orderId as the argument to the “setCompositeINstanceTitle” by clicking the “Insert Into Expression” button.  5) Cast the orderId argument using the string function. The final result should be  “ora:setCompositeInstanceTitle(string(bpmn:getDataObject(‘orderId’)))”. 
    It is important to cast the orderId to a string via the “string” function or else the setCompositeTitle() function may fail during runtime. Click OK, OK, and then OK again to return to the process model.

     

    XPath Functions
  8. Double click the “Start” activity.  Check the “Use Associations” check box and click the “Edit Data Associations” icon.

     

    Data Associations
  9. Drag and drop the “orderId” Process Data Object and map it to the “orderIdArg” argument.  Click OK and OK again to return to the process model.

     

    Map Start Arg
  10. The process should look something like the following:

     

    Process Model
  11. Save All.
  12. Deploy to your environment.
  13. Create an instance in the process using the number “1234”, you can do this using the EM, SoapUI, or another tool.
  14. Log into the EM. 
  15. Click on your deployed composite and view the instance that was just created.
  16. You should see something like the following:

     

    Composite Title/Name

Summary

Now with the ability to populate the Composite Instance Title/Name from within a BPM process, the EM can be used to search, troubleshoot, and correlate a BPM instance to a Composite Instance via the use of a business value.  With this trick up our sleeves, life becomes a little simpler for BPM developers and SOA admins to do their jobs.  Enjoy 🙂