Script to Parse XML in IBM BPM

We use XML parsing a lot during database calls. For retrieving data from a table it may return result of type “XMLElement”. In such cases we need to parse that in to an business object . Here I will show the same.

In my retrieve data integration service Im expecting result of type EmployeeDetails

Then in the Sql Excute nested service the return type is “XMLElement”

This above will return result of below type

This needs to be parsed as Business object to be sent as output


Parsing Script

if(tw.local.results != null && tw.local.results.childNodes && tw.local.results.childNodes.length > 0 ){
    var firstelement = tw.local.results.childNodes.item(0);
     tw.local.employeeData = new tw.object.EmployeeDetails();
     tw.local.employeeData.employeeId = firstelement.xpath("record/column[@name='EMPID']")[0].getText(); = firstelement.xpath("record/column[@name='EMPLOYEENAME']")[0].getText(); = firstelement.xpath("record/column[@name='PLACE']")[0].getText(); = firstelement.xpath("record/column[@name='PHONE']")[0].getText();
     tw.local.employeeData.designation = firstelement.xpath("record/column[@name='DESIGNATION']")[0].getText();
     tw.local.employeeData.department = firstelement.xpath("record/column[@name='DEPARTMENT']")[0].getText();
     tw.local.employeeData.qualification = firstelement.xpath("record/column[@name='QUALIFICATION']")[0].getText();
     tw.local.employeeData.address = firstelement.xpath("record/column[@name='ADDRESS']")[0].getText();

This results in below output variable

 Same way we can parse for other return types such as NameValuePair etc.

Please do comment if you have any questions . Hope this helps someone and have a good day!

Auto Conversion of BPM TwObject to Json and Json to TwObject

Mostly in any development project we are using json for the data interchanging. Let it be with in the application or calling any external application. It is no difference in BPM .If there is any need to call external system it would be easy to use json rather than Tw objects,XML and vice versa for external systems to call BPM.

If you are using BPM 8.6 version there is an JSAPI  available for conversion of TWObject to JSON

Check Here

toJSONString( boolean formatted) Returns the JSON representation of the object

tw.local.json =;

But this api may not work for the lower BPM versions. Moreover there is no JSAPI available to convert JSON object to TWObject.

To solve this problem we can use BPM JSON helper toolkit to convert TWObjects to JSON and JSON to TwObjects and it is based on json2.js To keep our Process App size down,instead of entire helper kit we can just add 2 files to server as dependencies.


Can be downloaded here : Git Download


Once we add these files now we can easily do what we required.

To convert TwObject to Json we need to call function convertTwToJSON(object) which is in Utils.js file

tw.local.json = BPMJSON.convertTwToJSON(;

Similarly to convert JSON to Twobject we use the below function = BPMJSON.convertJSONToTw(tw.local.json);

Below is one sample example:

Initially I’m creating two integration services


Here json variable is the output variable and data is the input variable to that service


Here data is the output variable and json is the input variable to this service.
Then Ive created a simple human service so that I will call these services.


Human service Diagram



Human service output

Here on click of convert to json the , JSONConvertor service is called and it returned the json. Same way we can use the json and convert to UI and directly bind that to UI.

NOTE : The point to be noted while converting json to Twobject , the output Tw object should exactly match with json structure or else it will throw an error.

This way we can easily work with Json even for complex business objects in bpm.

Hope it helps someone !

What is BPM and the history of IBM BPM


It will help your business to grow whatever it may be healthcare,finance,banking,insurance etc.,Everyone has some business process and they want management of that business process so that they can track it,make themselves aligned with the SLA’s and finally they can work efficiently on their business so that they can grow.

In technical terms,it can be defined as a field of operation management,that focuses on improving the corporate performance by managing and optimizing the company’s business process.

It will help to grow your business because you are going to do management of your business using the technology,what ever the technology it may be.

IBM BPM:It provides a platform where the business processes can be easily described,implemented,executed and monitored.

History of IBM BPM:

In 2005,IBM released a Business process management product called WPS (Websphere Process Server).It was designed to meet all the needs of a customer  from BPM perspective.It followed Service oriented architecture(SOA) paradigm.It means that customers would have business services and those would be aggregated together to build business solutions.

WPS came along with new open and business standard called Business Process Execution Language(BPEL).BPEL would solve all the business choreography needs.

(Choreography:There is no requirement that services need to be hierarchically composed.That means,two services may talk to each other.The protocol running between them is choreography)

This language can be visualized in a flow chart style diagram.The WPS provided IBM’s implementation of BPEL.So, with both SOA integration and BPEL IBM product,WPS came in to market.

But, unfortunately ,WPS could not capture 100% business market.WPS is more focusing on SOA principles. But competetors on more focussing on business users rather than technology users.It is more technical stuff and a business user could not sit and develop/capture their business process.To overcome this problem IBM came up with a new product called (IBM WebSphere Business Modeller) aimed at business users.But the problem is that WPS requiring migration from modeler to WPS for execution.

Acquisition of Lombardi:

A third party company called Lombardi called Teamworks which was a stiff competetor for  IBM WPS.

In 2010,IBM acquired Team Works and renamed as WebSphere Lombardi Edition(WLE) and the first release was in june,2010 i.e., WLE 7.1.In Dec,2010 WLE 7.2 version released.Although WLE replaced TeamWorks,we can still see the original name in few places.For example variable name starts with tw (eg:tw.local.text) .

WLE was successful but,customers were confused because IBM provides two products,i.e WPS and WLE.So to overcome this problem IBM came up with a single product,where they integrated the best parts of WLE and WPS in a single run time environment called IBM Business Process Manager(IBPM) and they released IBPM version 7.5.To maintain compatibility with the previous WPS and WLE customers,they kept many concepts of WPS and WLE by themselves.

Strength of IBPM:

Business processes are usually studied and captured by the business analysts and Bpm analysts.But they will have very less technical knowledge and they could not spend extensive time to translate business process in to automation design or implemetation.

But the biggest strength of IBPM is that with in few sessions anyone can capture the process in an intuitive diagram. After capturing the process,it can be play backed(run) to validate whether the process is fine or not.If we found any errors or misunderstandings we can easily make changes in real time in can be play backed again.This can be repeated until the correct process is captured.

The biggest differentiator of IBPM with other products is that it has interactive and real time iterative walk throuh capability.