Try OpenEdge Now
skip to main content
Application Developer's Guide
Developing applications with rollback support : Writing JavaScript code for rollback worksteps : Sample Javascript code
 

Sample Javascript code

In the following example, "jst" refers to JSTools class for execution of JavaScript codes. Users can invoke all getXXX() and setXXX() methods and also specialized tools such as sendEmail().
var name = jst.getDataSlotValue ("empName");
var salary = jst.getDataSlotValue ("empSalary");
jst.putDataSlot ("empName", name);
jst.putDataSlot ("empSalary", salary);
var adr = "ebms@savvion.com";
var subject = "Testing";
var content = "CONTENT";
jst.sendEmail(adr, subject, content);
jst.writeLog(Done);
In the following example, "pak" refers to the entire BP Server API. All API calls must start invoking pak.connect(<username>, <password>) and end with pak.disConnect().
Example:
var session = pak.connect(<username>, <password>);
var ebmsVersion = pak.getPAKVersion(session);
pak.disConnect(session);
In the following example, the keyword "Packages" invokes static Java methods.
Example:
Employee.java
package com.tdiinc;
public class Employee {
protected static String empName;
public static String getName () {
return empName;
}}
JavaScript code
function f1() {
var name = Packages.com.tdiinc.Employee.getName();
return (name);
} f1()