How to Perform REST Call from BPM Server Script

IBM BPM has provided a java connector in the system toollkit which will help performing this rest operation. But that is not very robust and doesn't allow us to perform all the kinds of REST operations. In this post I would like to illustrate on how to invoke a REST service from a server script.
Below is the script which can be used to perform a Rest Call from BPM Server sccript.

var client = new;
var op = new;

op.setParameter("param 2",tw.localvar2);


var auth = new"restapiuser","restapipass");
client.getState().setCredentials(null, null, auth);

try {
  var statusCode = client.executeMethod(op);
  tw.local.output = op.getResponseBodyAsString();

} finally {

parse the status

    tw.local.instanceId= tw.local.response.getElementByTagName("data").item(0).getElementByTagName("element").item(0).getText();
  //  tw.local.instanceId=tw.local.response.toString(true);

Also check the post to perform rest call in IBM with input as Entity.
Hope this post is help full !!!

Thanks for stopping by. If you like this post leave a comment, share it and do a g +1.

How to Convert TWObject to JSON

JSON has been very famous now a days, especially while using REST.
Here is the script to create a JSON out of a teamworks object.

Say I have tw object of type EMPLOYEE with the parameters (name, place,phone). After executing the script below it will give the JSON as below.


result :

tw.local.json  will have the value {"Employee":{"name":"abcd","place":"ongole","phone":"xxxxxx"}}


How to Implement Number Spinner Using Coach View and Jquery

In this post let us see on how to Implement Number Spinner using JQuery and Coach View. Below screen shot shows the Spinner created in IBM BPM 8.0 Coach.

IBM BPM Coach Number Spinner

jqeury-ui.js and jquery-1.10.2.min.js are the pre-requsites js files to create this. You can download these files from the links jquery-ui and jquery-1.10.2.min.js. Attach these files to the files section of IBM BPM as shown below.

Working with Dates in IBM BPM

Many of us (ibm bpm developers) are wondering on perform certain operation like comparing dates, find difference between dates and such stuff as Date not a simple type but is complex system object. But thanks to bpm suite, the implementation to do these operations are all already in place and if we give simple syntax which we use with simple types it will do the job. Here a some of the operations which I would like to illustrate in this post.

How to  Comparing date1 and date2 ?
Comparing dates is as simple  as comparing two integers.
Suppose I have two date variables tw.local.date1 and   tw.local.date2 .
In order  to compare dates we just have to use the statements as shown below.
    tw.local.date1 > tw.local.date2   or
    tw.local.date1 < tw.local.date2

Above statement will be evaluated to true or false in the similar way when used with integers.
Above statements will consider time stamp as well. If you want to check this irrespective of time, then  first set the hours, min and seconds for these dates to same values and then compare. You have to first set hours, seconds and then milliseconds.

How to Compare date to current date ?
For this, first we need to get the current date and store it in a variable.
var currentDate= new TWDate();
then set currentDate and  hours , seconds and milliseconds to same value and then compare like above.


Error : You have been automatically logged out for security reasons

Those who are working with IBM BPM  might have seen this error many a time, when you submit a coach or run an exposed service you might see the error message: "You have been automatically logged out for security reasons. Unfortunately, because of this we are unable to save your information at this time. Please run this task again to save your information."

Root Cause
There are several reasons why this error is thrown by IBM Business Process Manager. This document provides a list of all of the possible reasons and resolutions.

The possible causes of the error are:
• You are using a process application that was imported from WebSphere Lombardi Edition V7.x and it contains the old system toolkit dependencies.
• The CoachDesigner.xsl file, coach_designer.css file, or both files in your process application are not the stock files.
• You attempt to run the same task and submit the same coach from several browser windows.
• You might have a general Jave™Script syntax error in your coach in a custom HTML block.
• You have changed the URLs in IBM Business Process Manager configuration files after adding a front-end web server.
• You have configured IBM Business Process Manager to work with your Load Balancer.
• The IBM Business Process Manager server is not in the list of trusted sites for Microsoft Internet Explorer

IBM provide several ways to trouble shoot and  resolve the issue. Please follow the below provided link for more information.


How to Create Instance in BPM using Rest API?

There are different Methods to create instance in for BPD in IBM BPM from an external system using REST API.

1. Using Rest API url as shown below. This is the URL which is exposed by IBM BPM via REST API to start a BPD or trigger an instance for BPD from an external system.


In order to Use the above URL one should know the parameters like bpdId, snapshotId and ProcessAppId., which may change every time a new snapshot version is deployed. This is one of the disadvantage of using above method.

2. Another method is to create instance instance using RestAPI Start service method. Below shown is sample url for Start service.


In the above URL POC is teh Process App name and InitiateBPDService is service to be Invoked, which will contain the code to invoke the service.
In this service, we can use Invoke UCA  to trigger an instance for BPD or we can use web api methods in server script to initiate an instance for BPD(click here to see various method of triggering BPD).

Initiate BPD using Server script

Initiate BPD using UCA

You may find below links useful .
Invoke Service via Rest API
Various Methods to Trigger BPD

Sending Mail with Calender Appointment from IBM BPM

Create an ".ics " file using the teamworks "write Text file" connector, to some temporary location. Now send a mail with the ".ics" file as an attachment.On opening the file from outlook, the outlook calender appointment console will be opened and one can accept or Decline the appointment.If accepted the appointment will be added to the outlook calender.

ics calender, ibm bpm calender appointment, lombardi calender appointment, calender notifcation using ibm bpm, ibm bpm mail notifaction with calender appointment
Outlook mail Image


Auto-Complete using JQuery in heritage Coach

This Post will illustrate an example on how to implement auto-complete operation over a text-box in IBM BPM  Heritage coach (Not the new coach which comes in 8.x versions) using an Ajax service.

Steps for implementation:
Create an Ajax Service which will takes String value as input (variable name: text) and list of String as output and build the require logic inside the service. In this example, let create a service which get the users from LSW_USR table based on the input string value. Input and output structure is as shown in the below figure.

Create human service with a heritage coach, with one input text field (control Id: InputText0). And add a Custom Html and inlcude the below script.

Integrate BPM workflow with a UI in External system

         Many of us are wondering on how to create a BPM Application with User I in an external system. REST API is the first thing that comes to our mind. Create an instance using REST API url and then fetch task ids available for a particular instance using REST API url again and perform the operation on the screen in External system and complete the task by passing the inputs using REST URL. This is the first approach that many of us get to our mind, on seeing the above statement

There is another, yet simple approach came to us when we have this problem in front of us.

Using combination of External Activity, REST API and Message event.

          In the BPD, whenever there is a human interaction needed, place an external activity and attach an intermediate message event to the External activity. Here external activity is just a fool proof activity, to

How Coaches of 8.0 are different from Coaches of previous versions ?

Coach in IBM BPM 8.0 is a improvement of Coach in previous versions which is now called as heritage coach. A concept of Coach view is introduced in 8.0, which makes it possible to reuse parts of coaches in different Human Services. A coach can consits of one or more Coach Views. Another Big difference in Coach of 8.0 is introduciton of client-side model to coaches to apply Web2.0 appearance and behaviour. The Coach has data on the client, which is available to all of the Coach Views. That is, fields in different Coach Views that are bound to the same data object update without requiring a full-page refresh.

Instead of the one-button mechanism of Heritage Coaches, Coach Views use named boundary events. Programmers use boundary events for actions such as data updates with the server and transitions to other Coaches or services. For example, a Coach can have multiple buttons. In the human service diagram, you can wire each button to a different event. Any Coach View can declare and fire a boundary event. You are not limited to using only buttons to do so although, of the stock controls, only the button stock control can fire a boundary event. Furthermore, the programming for Coach Views consists entirely of client-side JavaScript. There is no need for server-side JavaScript.

Coaches support collaboration while Heritage Coaches do not. More than one person can work on the

Invoking IBM BPM Service using REST API from an external system (java system)

In this post, I would like demonstrate how to invoke a Lombardi service using via rest API, and how to pass the inputs and get back outputs. Let’s just pass two numbers (‘a’ and ‘b’) as input parametersand get back sum of these two numbers as the output parameter ‘sum’.

First of all let us know the restrictions on the services which can be invoked using REST API, you can very well find this on IBM BPM rest API documentation. Just for reference, only a human service or AJX service can be invoked using REST API URL.

In order to overcome the restriction on length of the URL which can become large because of the query parameters, the rest URL which will be used for invoking a Lombardi service is provided with POST method call.

Below shown is the format of the URL: