Try OpenEdge Now
skip to main content
Application Developer's Guide
Developing an application : Using JavaScript in a workstep : Integrating JavaScript : Using 'blserver' in JavaScripts
 
Using 'blserver' in JavaScripts
In Business Process Server applications, you can use JavaScripts to provide customized business logic for any workstep. You must frequently access the BP Server APIs to complete the business logic in the JavaScripts. For this, Business Process Server provides an inbuilt object ‘blserver’ that can access all APIs of the BP Server. Communication to the BP Server in the JavaScript code should start with a call to connect as:
var session = blserver.connect(<user>, <password>)
Ensure that you end the communication with a call to disconnect from the server as:
blserver.disConnect(session)
After a connection is established with the BP Server, all features exposed by the BP Server API are available for you to perform various tasks, such as:
1. Working with BP Server specific information such as version, or start time. For example:
a. BP Server version
var session = blserver.connect(<user>, <password>)
var session1 = blserver.getVersion(session)
blserver.disConnect(session)
b. BP Server start time
var session = blserver.connect(<user>, <password>)
var startTime = blserver.getStartTime(session)
blserver.disConnect(session)
c. BP Server information
var session = blserver.connect(<user>, <password>)
var info = blserver.getInfo(session)
blserver.disConnect(session)
2. Working with smart value objects (SVO)for the process template, process instance, workstep template, workstep instance, work item, and dataslot. For example:
a. Setting the process instance creator.
var session = blserver.connect(<user>, <password>)
var piName = jst.getProcessInstanceName()
var pi = blserver.getProcessInstance(session, piName)
pi.setCreator(<creatorname>)
pi.save()
blserver.disConnect(session)
b. Setting the due date of workstep instances.
var session = blserver.connect(<user>, <password>)
var piName = jst.getProcessInstanceName()
var wsName = jst.getWorkstepName()
var wsi = blserver.getWorkStepInstance(session, piName, wsName)
var duedate = new Packages.com.savvion.sbm.bizlogic.server.svo.DateTime (<date-string>)
wsi.setDueDate(duedate)
wsi.save()
blserver.disConnect(session)