Sun ONE logo     Previous      Contents     Index      Next     
iPlanet Process Manager, Version 6.5 Process Builder's Guide



Appendix A   JavaScript API Reference

This appendix is an API reference of the objects and methods you can use when writing JavaScript scripts for Process Manager.

The Process Manager Object Model includes the following objects:

  • "ProcessInstance" contains methods for accessing information about the current process.
  • "WorkItem" contains methods for accessing information about the current work item.
  • "ContentStore" contains methods for accessing the content store.
  • "CorporateDirectory" contains methods for accessing data about users in the Directory Server.
  • "User" exposes the user attributes that make up an LDAP user entry as publicly accessible properties.

The following global functions are also available for use in scripts:

All functions and methods are listed here:

ProcessInstance

A script can use the global function getProcessInstance() to get the processInstance for process in which the script is running.

Example:

var pi = getProcessInstance ();

The following methods can be called on the processInstance object:

getCreationDate

Returns a JavaScript date that represents the date when the process instance was first created.

Example:

var pi = getProcessInstance();

var creationDate = pi.getCreationDate();

getCreatorUser

Returns an object that contains the attributes of the creator user in the corporate directory.

Example:

var pi = getProcessInstance ();

var creator = pi.getCreatorUser ();

getData

Returns the value of the data field or undefined if the field is not defined. The returned value is in JavaScript format.

Parameters

  • fieldname

String of the field name whose value is being retrieved

Example

var pi = getProcessInstance ();

var cust_name = pi.getData( "customer_name" );

getEntityKey

Returns the entity key associated with the custom field whose name is passed as an argument. This key is stored in the process instance and is set using the setEntityKey method. The entity key is the primary key for the field, uniquely identifying it from other instances of the same custom field.

Parameters

  • fieldName

String of the name of the custom field for which you want to fetch the entity key.

Example:

var pi = getProcessInstance();

pi.getEntityKey("mySignature");

getEntryNodeName

Returns a JavaScript string containing the name of the entry point node where the current process instance was initiated. All process instances must start from an entry node, ensuring that this method never returns null.

Example:

var pi = getProcessInstance();

var entry = pi.getEntryNodeName() );

getExitNodeName

Returns a JavaScript string containing the name of the exit point node where the process instance has completed. If the process instance has not yet completed, returns null.

Example:

var pi = getProcessInstance();

var exitNodeName = pi.getExitNodeName();

getInstanceId

Returns the ID of the process instance, such as "2345". The id is generated by the engine to be unique across all process instances of all applications defined in the same cluster.

Example:

var pi = getProcessInstance();

var pid = pi.getInstanceId();

getPriority

Returns a JavaScript number representing the priority value of the current process instance. The priority value ranges from 1 (highest) to 5 (lowest). The priority value is derived from the value of a data element. If the data element's type is INT/FLOAT, the priority value is fetched from the data element's value. Otherwise, the default value 3 is returned.

Example:

var pi = getProcessInstance();

var priority = pi.getPriority();

getRoleUser

Returns a JavaScript User object that contains the attributes of the user that has been assigned to the role roleName. If a user is not associated with the role roleName yet, null is returned.

Parameters

  • roleName

String of the name of the role whose full DN is returned.

Example:

var pi = getProcessInstance ();

var u = pi.getRoleUser( "role1" );

getTitle

Returns the current title string associated with the process instance. Calling this method is similar to calling getData() on the title data field and casting the value to a string. If the title data field has a type other than TEXT/LONG TEXT, returns a textual representation of the data element's value.

Example:

var pi = getProcessInstance();

var title = pi.getTitle();

setData

Associates the object fieldValue with the data element fieldName. The object passed by fieldValue can be any valid JavaScript object (such as String, Date, Array). The object can be a Java object if the data element is a custom field.

Parameters

  • fieldName

String of the name of the data element whose value is modified.

  • fieldValue

Object which is the value associated with the data element fieldName.

Since each data element is configured with a particular data type which is set at design time in Process Builder, be aware of the following data conversion guidelines:

Data element type

fieldValue type

fieldValue converted to...

TEXT/LONGTEXT

 

any type

 

String

 

INT

 

String

 

int

 

INT

 

Integer

 

int

 

FLOAT

 

String

 

float

 

FLOAT

 

Integer

 

float

 

DATE/DATETIME

 

String

 

Date

 

DATE/DATETIME

 

Date

 

Date

 

Example:

var pi = getProcessInstance ();

pi.setData( "customer_name", "Joe" );

//Set value for custom field

//

var custAcct = new Packages.com.acme.Account();

pi.setData( "customer_acct", custAcct );

setEntityKey

Sets the entity key of a custom field. The entity key is the primary key for the field, uniquely identifying it from other instances of the same custom field. The entity key is always available from the process instance, and is stored with the rest of the application data.

Parameters

  • fieldName

String of the name of the custom field you want to modify.

  • value

Object which is the value of the custom field's entity key.

Example:

var pi = getProcessInstance() ;

pi.setData ("mySignature" , pi.getData("signature") ) ;

pi.setEntityKey("mySignature" , "bob") ;

setRoleById

Changes the user associated with the role roleName by specifying the new user's ID via userId. Returns true if userId corresponds to an actual user in the corporate directory and the user associated with roleName is changed. Returns false if userId does not correspond to an actual user entry and roleName is left unchanged.

Parameters

  • roleName

String of the name of the role to alter.

  • userDN

String of the Id of the user to associate with roleName.

Example:

var pi = getProcessInstance ();

pi.setRoleById( "myRoleName", "joe" );

WorkItem

A script can use the global function getWorkItem() to get the work item in which the script is running.

Example:

var wi = getWorkItem();

The following methods can be called on the workItem object:

addUserAssignee

addUserAssignee(userID)

Adds the given user as an assignee for the work item.

Parameters

  • userID

User ID of the user to be added as an assignee.

The following script adds the user whose uid is jocelynb as an assignee to the work item.

Example:


var wi = getWorkItem();
wi.addUserAssignee("jbecker");

addGroupAssignee

addGroupAssignees(groupName)

Adds the members of the given group as assignees for the work item.

Parameters

  • groupName

Name of the role.

assignees

This method returns a JavaScript array of the user ids of the assignees of a work item. Since automated activities are performed by Process Engine and do not require an assignee, use this method only from a user activity.

Example:


var wi = getWorkItem();
var assignees = wi.assignees();

for( var i = 0; i < assignees.length; i++)
   doSomethingForEachAssignee(assignees[ i ] ;


extend

Extends the duration of the work item by pushing out its expiration date. If the work item was expired, this function removes the expired flag.

Parameters

  • newDate

Date object for the new expiration date for the work item.

Example:

var wi = getWorkItem();

var now = new Date();

// Set extension date to 1 hour in the future

var newDate = new Date( now.getTime() + (1 * 60 * 60 * 1000) );

wi.extend( newDate );

getCreationDate

Returns a JavaScript date that represents the creation date of the work item.

Example:

var wi = getWorkItem();

var wiCreationDate = wi.getCreationDate();

getExpirationDate

Returns a JavaScript Date object that represents the expiration date of the work item.

Example:

var wi = getWorkItem();

var expDate = wi.getExpirationDate();

getNodeName

Returns the name of the workitem.

hasExpired

Returns true if the work item has expired or false if it has not expired. If the work item has already expired, but has been extended via the extend() method, hasExpired() returns false if called again.

Example:

var wi = getWorkItem();

// if the work item has not expired, then expire it in 1 minute

if( wi.hasExpired() == false )

   expireIn( 1, "minutes" );

isStateActive

Returns true if the work item is active or false if the work item is inactive. A work item is considered active if there is only one assignee currently assigned to it. If a work item has been assigned to a group, the work item is not active, but running. Once one member of the group elects to work on the item, it is considered active.

isStateRunning

Returns true if the work item is running or false if it is not running. A work item is running if more than one user is assigned to it. Once a user starts the work item, the work item changes state from running to active.

isStateSuspended

Returns true if the work item is suspended or false if it is not suspended. You can suspend a work item through Process Administrator or by calling suspend().

Example:

var wi = getWorkItem();

if( wi.isStateSuspended() )

   wi.resume(); //resume the work item immediately

isUserAssignee

Tests whether a user is an assignee of the work item or not.

Parameters

  • userID

String of the user ID.

Example:

// If chowdary is not an assignee, add him as one

var wi = getWorkItem();

if (wi.isUserAssignee("chowdary") == false)

   wi.addUserAssignee("chowdary")

moveTo

Move the current work item to the activity specified in activityName. Only activities associated with a virtual transition can use this method. moveTo() can only be called from expiration handler scripts and completion scripts.

Note that moveTo() doesn't actually involve "moving." Rather, the current work item is destroyed and a new work item is created at the new activity.

Parameters

  • activityName

String of the name of the activity to which to move the work item.

Example:

var wi = getWorkItem(); //inside the expiration handler script

var activityName = "expired item";

wi.moveTo( activityName );

removeAssignees

removeAssignees()

Removes all assignees from the workitem.

Example:

The following script removes all existing assignees from a work item and adds the user whose ID is jocelynb as the sole assignee.


var wi = getWorkItem();
wi.removeAssignees();
wi.addUserAssignee("jocelynb");

resume

This function reactivates a suspended work item. If the work item is assigned to more than one user, the work item's state is set to running. If there is only one assignee, the work item's state is set to active.

Example:

var wi = getWorkItem();

if( wi.isStateSuspended() )

   wi.resume(); //resume the work item immediately

setExpirationDate

Sets the expiration date of the work item. If the work item has expired, use the extend() function instead of setExpirationDate() to extend the expiration date, since extend() removes the expired flag and setExpirationDate() does not.

Parameters

  • expDate

Date object for the expiration date for the work item.

Example:

var wi = getWorkItem();

var now = new Date();

//Set expiration date to 1 hour in the future

var expDate = new Date( now.getTime() + (1 * 60 * 60 * 1000)

);

wi.setExpirationDate( expDate );

suspend

This function makes the work item inactive. Users cannot work with the work item until it has been resumed through Process Administrator or via a call to resume().

Example:

var wi = getWorkItem();

wi.suspend();

ContentStore

Scripts can use the global function getContentStore() to get a contentStore object connected to the content store of the application. There are three different ways to call the function:

  • getContentStore ();
  • Without parameters, this function returns the content store defined by the application. The returned object is configured with the URL, username, and password that are specified in Process Builder.

  • getContentStore (httpURL, username, password);
  • When called with the above three parameters, getContentStore() creates a new content store with the specified parameters passed in. The returned object is a content store rooted at the specified httpURL. The content store uses the username and password to authenticate against.

  • getContentStore (httpURL, username, password, timeout);
  • This form is identical to the previous form except for an additional timeout, specified in seconds, on HTTP connections.

The following methods can be called on the contentStore object:

copy

copy(srcURL, dstURL)

Copies the content at the srcURL to the dstURL. Both URLs have to be on the same content store. If dstURL already exists, it is overwritten. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

  • srcURL

A String of an HTTP URL or URI of the content in the content store object.

  • dstURL

A String of an HTTP URL or URI of the content in the content store object.

Example:


var cs = getContentStore();
var result = cs.copy( cs.getBaseURL ( "shopping/docs" ) +
   "myFile.html",
var httpcode = cs.getStatus ( result );
if (httpcode == 200)
{
   // it went OK, so continue
}

download

download(url, file)

Downloads the content at the url into the specified file. If a username and password is specified for this content store, they are used in the request to retrieve the content. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

  • file

File where the content is stored; if exists, it will be overwritten.

Example:


var cs = getContentStore();
var result = cs.download ( cs.getBaseURL() + "myFile.html" ,
   "C:/myFile.html" );
var httpcode = cs.getStatus( result );
if (httpcode == 200)
{
   // it went OK so continue
}


exists

exists(url)

Checks if the URL exists on the content store. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

Example:


var cs = getContentStore();
var result = cs.exists( cs.getBaseURL ( "shopping/docs" ) + "myFile.html" );
var httpcode = cs.getStatus ( result );
if (httpcode == 200)
{
   // file exists,so continue
}


getBaseURL

getBaseURL()

Returns the root URL of this content store.

See getRootURL for examples.

getBaseURL

getBaseURL(path)

Returns a url which appends the given path to the content store root url.

Parameters

  • path

A String of the relative path segment.

Example:

var cs = getContentStore();

var shoppingDocBaseURL = cs.getBaseURL("shopping/docs");

getBaseURL

getBaseURL(path, instanceid)

Returns a URL which appends the path and the instanceid to the content store root URL.

Parameters

  • path

A String of a relative path segment.

  • instanceid

An integer instance id of the process.

Example:

var pi = getProcessInstance();

var cs = getContentStore();

var myURL= cs.getBaseURL("shopping/docs", pi.getInstanceId());

getContent

getContent (url)

Returns a String of the content at the specified url, where url describes either an HTTP URL or URI of the content in the content store object. A URI is a path segment only, specified as an absolute or relative pathname.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

On an HTTP content store, getContent( ) is implemented as a GET request against the server. If a username and password have been specified for this content store, they will be used in the request to retrieve the content.

If the content cannot be retrieved or doesn't exist, getContent( ) returns null. Call the exists( ) method to check whether the URL exists in the content store. See also store( ) and upload( ).

Example:


var cs = getContentStore();
// Relative URI
var content = cs.getContent ( "myFile.html" );

// Absolute URI
var content = cs.getContent ( "/CS/CheckOut/basket.xml" );

// If URL, then the host and port portion of the URL must be
// that of the content store URL. This is typically returned
// by the getBaseURL() method.
var content = cs.getContent ( cs.getBaseURL() +
   "CheckOut/basket.xml" )


getException

getException(result_string)

Gets the exception in string format that has occurred in the operation move(), copy(), upload(), download(), store(), exists(), initialize(), remove(), mkdir(), rmdir().

Parameters

  • result_string

A String of the results from one of the methods listed above.

Example:


var cs = getContentStore();
// Remove a file from the content store
var fileName = cs.getBaseURL ("shopping/docs") + "myFile.html" )
var result = cs.remove(fileName);

// If something went wrong, put an error in the error log
if ( cs.isException (result))
{
   var e =    new Object();
   e.exceptionString = cs.getException(result);
   logErrorMsg ("FILE_REMOVAL_ERROR", e);
}

getRootURL

getRootURL ()

Returns a string of the root URL of the content store, including the ending /. This is a string version of the URL for the content store as specified in Process Builder.

Example:

var cs = getContentStore();

var rootURL = cs.getRootURL();

getSize

getSize(url)

Returns the size in bytes of the content of the specified URL at the content store. On any error, -1 is returned.

Note that in certain rare circumstances, the length of the content of such a URL cannot be established.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

Example:

var cs = getContentStore();

var size = cs.getSize( cs.getBaseURL ( "shopping/docs" ) + "myFile.html" );

getStatus

getStatus(result)

Returns the status of the last successful Content Store operation by one of the methods: move(), copy(), upload(), download(), store(), exists(), initialize(), remove(), mkdir(), rmdir().

Parameters

  • result

A String of the results of one of the methods listed above.

Example:


var cs = getContentStore();
var result = cs.remove( cs.getBaseURL ( "shopping/docs" ) + "myFile.html" );
if ( cs.getStatus(result) != 200)
{
   // there was an error, so do something,
   // perhaps put an error in the error log
}

getVersion

getVersion()

Returns the version string of the ContentStore implementation. Currently, this value is 0.1999100221-001.

Example:

var cs = getContentStore();

var version = cs.getVersion();

initialize

initialize(url)

Initializes the URL with basic content so the URL exists on the Content Store. This method returns either the status code from the content store for the operation or an exception. Note that no exception is actually thrown. To see if an exception is returned, call isException() on the return value from this method and call getStatus() to get the numeric HTTP protocol status of this content store request.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

Example:


var cs = getContentStore();

var myURL = cs.getBaseURL("shopping/docs") + "myFile.html";
var result = cs.initialize (myURL);
var httpcode = cs.getStatus ( result );

// 201 or 204 indicates an error
if (httpcode == 201 || httpcode == 204)
{
   var error1 = new Object();
   error1.operation = "initialization";
   error1.URL = myURL;
   logErrorMsg ("URL_INITIALIZATION_ERROR", error1);
}

isException

isException(exception)

Checks if the result string from move(), copy(), upload(), download(), store(), exists(), initialize(), remove(), mkdir(), rmdir() is an exception.

Parameters

  • exception

A String of the results of one of the methods of Content Store that can return an exception.

Example:


var cs = getContentStore();

var myURL = cs.getBaseURL ( "shopping/docs" ) + "myFile.html";
var result = cs.remove( myURL);

// If an exception occurred, put an error in the error log
if ( cs.isException ( result ))
{
   var error1 = new Object();
   error1.operation = "removal";
   error1.URL = myURL;
   logErrorMsg ("CONTENT_STORE_REMOVAL_ERROR", error1);
}

list

list(url)

Gets the container content (folder) listing of this content store container.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

mkdir

mkdir (URLString)

Creates the appropriate folder structure on the web server being used as the content store. The URLString must be a full path name to the new directory. If the specified directory already exists, nothing happens. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

  • URLString

A String of an HTTP URL or URI of the content in the content store object.

Example:


var cs = getContentStore();

// Make a new directory in the content store
var dirName = "shopping/docs";
var result = cs.mkdir( cs.getBaseURL ( dirName) );

// If an exception occurred, put an entry in the error log
if (cs.isException ( result ))
{
   var error1 = new Object();
      error1.directoryName = dirName;
   logErrorMsg ("CONTENT_STORE_MAKE_DIRECTORY_ERROR", error1);
}

move

move (URLString1, URLString2)

moves the file from the URLString1 to URLString2, overwriting any file that already exists at the destination file name. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

If the file to be moved URLString1, does not exist, this function gives an error.

Both file names must be full pathnames. The following code moves the file tempdoc.html from the temp directory to doc1.html in the docs directory on the web server pm.company.com.

Example:

var myStore = getContentStore ();

var pi = getProcessInstance ();

var pid = pi.getInstanceId();

var result = myStore.move("http://pm.company.com/temp/tempdoc.html",

      "http://pm.company.com/docs/doc1.html");

Note that the move() function does not create directories -- use mkdir() to create a directory before moving a file to it.

remove

remove(url)

Deletes the content at the specified URL. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

Example:


var cs = getContentStore();
var myURL = cs.getBaseURL ("shopping/docs") + "myFile.html"
var result = cs.remove(myURL);

// If an error occurred, put an entry in the error log
if (cs.isException (result) )
{
   var error1 = new Object();
   error1.operation = "removal";
   error1.URL = myURL;
   logErrorMsg ("CONTENT_STORE_REMOVAL_ERROR", error1);
}

rmdir

rmdir(url)

Removes the container (folder) at the specified URL. The folder must be empty to be removed or an error is returned. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

  • url

A String of an HTTP URL or URI of the content in the content store object.

Example:

var cs = getContentStore();

var result = cs.rmdir( cs.getBaseURL ( "shopping/docs" ) );

store

store (content, url)

Stores the content specified by content in the given url. If a username and password has been specified for this content store, they are used in the request to store the content. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

content

A String of the content to store in the content store as this URL.

url

A String of an HTTP URL or URI of the content in the content store object.

Example:


var cs = getContentStore();
var content = "<body><b>Hello</b> world ... </body>";
// Relative URI
var result = cs.store (content, "myFile.html" );
// Absolute URI
var result = cs.store (content, "/CS/myFile.html" );
// Absolute URL (for historical reasons)
var result = cs.store (content, cs.getBaseURL() + "myFile.html");

upload

upload(file, url)

Uploads the file content to the URL specified. If a username and password has been specified for this content store, they are used in the request to upload the file. Returns a result string that can be passed to content store methods such as getStatus(), getException() and isException() to test for the result of the operation.

Parameters

file

File to upload.

url

A String of an HTTP URL or URI of the content in the content store object.

Example:

var cs = getContentStore();

var result = cs.upload ( "C:/myFile.html", cs.getBaseURL() + "myFile.html" );

CorporateDirectory

Scripts can use the global function getCorporateDirectory() to get a corporateDirectory object that is connected to the corporate directory in the Directory Server for the cluster.

Example:

var corp = getCorporateDirectory ();

Scripts can then use the corporateDirectory object to access and modify information about users in the corporate directory.

The following methods can be called on the corporateDirectory object:

addUser

addUser (userDN, attributes, objectClasses)

Adds a user to the directory. The user's Distinguished Name (DN) is specified by userDN. The attributes for the user are specified as a JavaScript associative array indexed by attribute name. The objectClasses parameter specifies any additional object classes as a JavaScript array. If the addition of the user is successful, returns true, otherwise returns false.

  • userDN

A String of the distinguished name (DN) for the new user entry.

  • attributes

An Object that is a table of key/value pairs specifying user attributes.

  • objectClasses

An Array of object classes with which the user entry is compliant.

Example:


var attrs = new Object();
attrs[ "uid" ] = "joe";
attrs[ "cn" ] = "Joe Cool";
attrs[ "sn" ] = "Cool";
attrs[ "mail" ] = "joe@acme.com";
attrs[ "favoriteColor" ] = "green";
// Specify additional objectclasses
var OCs = new Array( "favoriteColorOC" );
// add the new user
cd.addUser( "uid=joe, ou=People, o=acme.com", attrs, OCs );


deleteUserByCN

deleteUserByCN(userCN)

Deletes the user entry specified by the Common Name (CN) userCN from the corporate directory. Returns true if the deletion is successful. Returns false if the deletion failed.

  • userCN

A String of the common name (CN) for the user entry to be deleted.

Example:


var cd = getCorporateDirectory();
var joe = cd.getUserById( "joe" );
// Delete the user
cd.deleteUserByCN( joe.cn );


deleteUserByDN

deleteUserByDN(userDN)

Deletes the user entry specified by the Distinguished Name (DN) userDN from the corporate directory. Returns true if the deletion is successful. Returns false if the deletion failed.

  • userDN

A String of the distinguished name (DN) for the user entry to be deleted.

Example:

var cd = getCorporateDirectory();

var joe = cd.getUserById( "joe" );

cd.deleteUserByDN( joe.getDN );

deleteUserById

deleteUserById(uid)

Deletes the user entry specified by userID from the corporate directory. Returns true if the deletion is successful. Returns false if the deletion failed.

  • userDN

A String of the DN for the user entry to be deleted

Example:


var cd = getCorporateDirectory();
var joe = cd.getUserById( "joe" );
cd.deleteUserByCN( joe.getUserId());


getUserByCN

getUserByCN(userCN)

Returns the user entry corresponding to the Common Name (CN) userCN as a JavaScript User object. User object is a Process Manager-specific object. Returns null if no user entry corresponds to userCN.

  • userCN

A String of the common name (CN) of the user entry to be retrieved.

Example:


var cd = getCorporateDirectory();
var joe = cd.getUserByCN( "Joe Cool" );

getUserByDN

getUserByDN (userDN)

Returns the user entry corresponding to the Distinguished Name (DN) userDN as a JavaScript User object. User object is a Process Manager-specific object. Returns null if no user entry corresponds to userDN.

  • userDN

A String of the distinguished name (DN) of the user entry to be retrieved.

Example:


var cd = getCorporateDirectory();

var joe = cd.getUserByDN( "uid=joe, ou=People, o=acme.com" );


getUserById

getUserById (uid)

Returns the user entry corresponding to the user id userId as a JavaScript User object. The User object is a Process Manager-specific object. Returns null if no user entry corresponds to userId.

  • uid

A String of the User ID for the user entry to be retrieved.

Example:


var cd = getCorporateDirectory();
var joe = cd.getUserByID( "joe" );

modifyUserByCN

modifyUserByCN (userCN, attrName, attrValue, operation)

  • userCN

A String of the common name (CN) of the user entry to be modified.

  • attrName

A String of the name of the user entry attribute to modify.

  • attrValue

A String of the value of the user entry attribute to modify.

  • operation

A String of the modification operation to be performed.

The type of modification is specified by the operation, which can have the following values:

ADD: adds the attribute attrName with the value attrValue to the user entry. If attrName has multiple values, the operation can result in multiple instances of attrName in the user entry. attrName should be a valid attribute of one of the object classes with which the user entry complies.

REPLACE: replaces the value currently associated with attrName with the new value attrValue.

DELETE: deletes attrName from the user entry.

Example:


var cd = getCorporateDirectory();
cd.modifyUserByCN( "Nikki Beckwell",
   "favoriteColor", "blue", "Add");

modifyUserByDN

modifyUserByDN (userDN, attrName, attrValue, operation)

Modifies the user entry specified by the Distinguished Name (DN) userDN in the corporate directory. Returns true if the modification is successful. Returns false if the modification fails.

  • userDN

A String of the distinguished name (DN) of the user entry to modify.

  • attrName

A String of the name of the user entry attribute to modify.

  • attrValue

A String of the value of the user entry attribute to modify.

  • operation

A String of the modification operation to perform.

The type of modification is specified by the operation, which can have the following values:

ADD: adds the attribute attrName with the value attrValue to the user entry. If attrName has multiple values, the operation can result in multiple instances of attrName in the user entry. attrName should be a valid attribute of one of the object classes with which the user entry complies.

REPLACE: replaces the value currently associated with attrName with the new value attrValue.

DELETE: deletes attrName from the user entry.

Example:


var cd = getCorporateDirectory();
cd.modifyUserByDN( "uid=joe, ou=People, o=acme.com",
   "favoriteColor", "blue", "ADD" );
cd.modifyUserByDN( "uid=carol, ou=People, o=acme.com",
   "favoriteColor", "red", "REPLACE" );
cd.modifyUserByDN( "uid=barbara, ou=People, o=acme.com",
   "favoriteColor", "", "DELETE" );

modifyUserById

modifyUserById (userID)

  • userID

String

A String of the User ID of the user entry to modify.

  • attrName

String

A String of the name of the user entry attribute to modify.

  • attrValue

String

A String of the value of the user entry attribute to modify

  • operation

String

A String of the modification operation to perform.

The type of modification is specified by the operation, which can have the following values:

ADD: adds the attribute attrName with the value attrValue to the user entry. If attrName has multiple values, the operation can result in multiple instances of attrName in the user entry. attrName should be a valid attribute of one of the object classes with which the user entry complies.

REPLACE: replaces the value currently associated with attrName with the new value attrValue.

DELETE: deletes attrName from the user entry.

Example:


var cd = getCorporateDirectory();
cd.modifyUserByCN( "nbeckwell","favoriteColor", "blue", "ADD" );


User

The User object has publicly accessible methods and exposes the user attributes making up an LDAP user entry. You can treat the User object as a hashtable of attribute key/value pairs where the keys are the attribute names as they appear in the LDAP entry. In the following code sample, you can also access the attribute favoritecolor, which is an attribute available from the user joe's entry.

Example:


var cd = getCorporateDirectory();
var u = cd.getUserById( "joe" );
var email = u.mail;
var favColor = u.favoritecolor;

The following methods can be called on the User object:

getUserId

getUserId()

Returns the user ID for the current user. The user ID attribute can also be accessed directly as the uid property of the user object.

Example:


var cd = getCorporateDirectory();
var u1 = cd.getUserByDN( "uid=joe, ou=People, o=acme.com" );
var id1 = u1.getUserID();

var pi = getProcessInstance();
var u2 = pi.getCreatorUser();
var id2 = u2.getUserId() );

Logging and Error Handling Global Functions

The following global functions are available for adding entries to error, informational, and history logs.

logErrorMsg

logErrorMsg (label, context)

Adds an entry in the error log of the application. This information is displayed to the administrator when viewing the error log.

  • label

String of the label for the error log's entry.

  • context

(Optional) Object that is a Hashtable of key/value pairs to print in the log entry.

The following code could be used in a completion script or automation script to log an error message when a user tries to submit a document for review when the document is too long.

Example:


// LOG AN ERROR MESSAGE
var pi = getProcessInstance():
var author = pi.getData("author");
var docName = pi.getData("docName");
var pageCount = parseInt (pi.getData("pageCount"));

if (pageCount > 5000) {
   var error1 = new Object ();
   error1.author = author;
   error1.docName = docName;
   error1.pageCount = pageCount;
   logErrorMsg ("PAGE_COUNT_TOO_LONG", error1);
}


logHistoryMsg

logHistoryMsg (label, comment)

Adds a row in the history log. This information is displayed to users when viewing Details & History in a work item list.

  • label

String of the label for the entry in the history log.

  • comment

(Optional) String of an additional comment for the history event.

The label is a string to be used as the label for the entry in the history log, and the optional argument comment is a string describing the entry.

Use this function to add information for the users about the work items. The following code could be used in a completion script to add details when an author submits a document for review.

Example:


// LOG A HISTORY MESSAGE
var pi = getProcessInstance():
var author = pi.getData("author");
var docName = pi.getData("docName");
var pageCount = parseInt (pi.getData("pageCount"));

logHistoryMsg ("Doc Submitted for Review",
   " \nAuthor: " + author +
   " \nDocument name: " + docName +
   " \nPage count: " + pageCount);

logInfoMsg

logInfoMsg(label, context)

Adds an entry in the info log of the application. This information is displayed to the administrator when they view the info log.

  • label

String of the label for the entry in the history log.

  • context

(Optional) Object that is a hashtable of key/value pairs to print in the log entry.

The label is a string to be used as the label for the entry in the info log, and the optional argument context is an object that has a variable for each property of the info message.

Use this function to show information about the execution of scripts. This is particularly useful for viewing the progress of script execution while debugging scripts. The following code could be used in a completion or automation script to log information about a document that has been submitted for review.

Example:


// LOG AN INFO MESSAGE
var pi = getProcessInstance():
var author = pi.getData("author");
var docName = pi.getData("docName");
var pageCount = parseInt (pi.getData("pageCount"));

var info1 = new Object ();
info1.author = author;
info1.docName = docName;

logInfoMsg ("DOC_SUBMITTED_FOR_REVIEW", info1);

logSecurityMsg

logSecurityMsg (label, context)

Adds an entry in the security log of the application. This information is displayed to the administrator when they view the security log.

  • label

String of the label for the entry in the security log.

  • context

(Optional) Object that is a hashtable of key/value pairs to print in the log entry.

The label is a string to be used as the label for entry in the security log, and the optional argument context is an object that has a variable for each property of the error message.

The following code could be used in a completion script or automation script to log a warning when an unauthorized user tries to perform a task that accesses an external database.

Example:


// LOG A SECURITY MESSAGE
var pi = getProcessInstance():
var username = pi.getData("username");
var password = pi.getData("password");
var externalDB = pi.getData("externalDBName");

var securityError1 = new Object ();
securityError1.username = username;
securityError1.password = password;
securityError1.externalDB = externalDB;

logSecurityMsg ("EXTERNAL_DB_ACCESS_NOT_ALLOWED", securityError1);

Assignment, Completion, and Email Scripts

This section lists the predefined assignment, completion, and email scripts available in Process Automation Edition. These predefined scripts (which are also global functions) can be called from other scripts. For example, an expiration handler script could call the predefined function toUserById(). The value returned by toUserById() could in turn be passed to the assignTo() method on a work item. The assignTo() method would then re-assign the work item to a user with a given user ID.

The global functions in this section are:

checkParallelApproval

checkParallelApproval (dataField, stopAction)

This function is meant for use as a completion script for work items that use the toParallelApproval() assignment script. The dataField must be the name of the data field that was specified in toParallelApproval(), and is used to keep track of who has completed the work item so far. The stopAction is the name of the action that a user can take to stop the approval process.

  • dataField

String of the name of a data field.

  • stopAction

String of the name of an action.

If an activity (work item) uses the toParallelApproval() assignment script, the activity should have two possible actions for the assignees to take when they complete the work item. One should indicate approval, and the other should indicate disapproval. The activity should also use the checkParallelApproval() completion script, which performs the "disapproval" action as soon as any one assignee selects it, the theory being that it takes everyone to approve the work item, but only one dissenter to disapprove it.

Example:

checkParallelApproval( "trackerField", "Reject" );

defaultNotificationHeader

defaultNotificationHeader()

Returns the default notification header for a notification message body. The header contains information about the current work item, such as the current activity name, the process instance ID, the creation date of the process instance and the expiration date (if any).

This function may be used as the notification body script by itself, or may be embedded in your own notification body script. You may also use this function from a template evaluated using evaluateTemplate(). The function may only be used successfully from a script associated with a notification; if used anywhere else, an empty string is returned.

The text returned from this function will depend upon the content-type of the notification. If the content-type is text/html, the header will be a series of HTML tags; if the content-type is text/plain, the header will be plain text.

Example:


function emailBody( )
{
var body = "Email message body <br>";
body += defaultNotificationHeader();
return body;
}

defaultNotificationSubject

defaultNotificationSubject()

Returns the default notification subject for the notification subject line. The subject contains information about the current process instance, such as the process instance ID the priority and the title string.

This function may be used as the notification subject script by itself, or may be embedded in your own notification subject script. The function may only be used successfully from a script associated with a notification; if used anywhere else, an empty string is returned.

Example:


function emailSubject( )
{
var subject = "Subject: " + defaultNotificationSubject();
return subject;
}

emailById

emailById(userId)

Returns a string of comma-delimited email addresses for the user with the given user ID. The mail attribute for the user must contain a valid email address in the corporate user directory. If the mail attribute of the user does not have a value, this function logs an error and returns null. This function is intended for use as a notification script, but can be used anywhere that a string of email addresses is needed.

  • userId

String of the User Id whose email address is to be returned.

Example:

emailById( "joe" );

emailOfAssignees

emailOfAssignees()

Returns a string of comma-delimited email addresses for all the assignees of the work item. The mail attribute for each assignee must contain a valid email address in the corporate user directory. If the mail attribute is empty for any assignee, no address is added to the string for that assignee. If no assignee has a value in their mail attribute, the function logs an error message and returns null. This function is intended for use as a notification script, but can be used anywhere that a string of email addresses is needed.

Example:

emailOfAssignees();

emailOfCreator

emailOfCreator()

Returns a string of the email address of the user who created the process instance. The user's mail attribute must contain a valid email address in the corporate user directory. If the mail attribute of the user does not have a value, this function logs an error and returns null. This function is intended for use as a notification script, but can be used anywhere that a string of email addresses is needed.

Example:


var pi = getProcessInstance();
var creatorEmail = emailOfCreator();
pi.setData( "creatorEmail", creatorEmail );

emailOfRole

emailOfRole(roleName)

Returns a string of the email address of the user performing the given role. The user's mail attribute must contain a valid email address in the corporate user directory. If the mail attribute of the user does not have a value, this function logs an error and returns null. This function is intended for use as a notification script, but can be used anywhere that a string of email addresses is needed.

  • roleName

String of a role name

Example:

emailOfRole( "reviewer" );

randomToGroup

randomToGroup(groupName)

This function returns an array containing a user ID of one member of the group. The group member is selected at random. This function is intended to be used as an assignment script but can be used anywhere that an array of user IDs is needed.

  • groupName

String of the name of a group.

Example:


var userArray = randomToGroup( "helpDesk" );


toCreator

toCreator()

Returns a JavaScript array with the user ID of the user who created the process instance. This method is the default assignment script assigned to user activities when a node is created on the Process Map.

Example:


var creatorArray = toCreator();

var creator = creatorArray[ 0 ]);


toGroup

toGroup(groupName)

Returns the qualified role name of the group. If the parameter groupName does not correspond to an actual group in the application's Groups and Roles folder, returns null.

  • groupName

String of the name of the group.

toManagerOf

toManagerOf (userId)

This function returns an array containing the user ID of the manager of the user with the given user ID. The manager attribute of the given user must contain a DN in the corporate user directory. This function is intended to be used as an assignment script but can be used anywhere that an array of user IDs is needed.

  • userId

A String of a user ID.

Example:


var managerArray = toManagerOf( "mike" );
var manager = managerArray[0];


toManagerOfCreator

toManagerOfCreator()

This function returns an array containing the user ID of the manager of the creator of the process instance. The manager attribute of the creator user must contain a DN in the corporate user directory. This function is intended to be used as an assignment script but can be used anywhere that an array of user IDs is needed.

Example:


var managerArray = toManagerOfCreator();
var creatorManager = managerArray[ 0 ];


toManagerOfRole

toManagerOfRole(role)

This function returns an array containing the user ID of the manager of the user defined as the given role. The manager attribute of the user fulfilling the role must contain a DN in the corporate user directory. This function is intended to be used as an assignment script but can be used anywhere that an array of user IDs is needed.

  • role

String of a name of the role.

Example:


var managerArray = toManagerOfRole( "reviewer" );
var reviewerManager = managerArray[ 0 ];


toParallelApproval

toParallelApproval(arrayOfUserDNs, dataField)

This function should be used as an assignment script to assign a work item to several users who must all complete the work item. The arrayOfUsers argument is an array of user IDs, and dataField is a data field that keeps track of who has performed the work item and who still needs to do it. This field is a computed field of length 2000 that must add to the data dictionary.

  • arrayOfUsers

Array of user IDs.

  • dataField

String of a name of a data field in the current process.

If an activity (work item) uses the toParallelApproval() assignment script, the activity should have two possible actions for the assignees to take when they complete the work item. One action should indicate approval, and the other should indicate disapproval. The activity should also use the checkParallelApproval() completion script, which performs the "disapproval" action as soon as any one assignee selects it. The idea is that it takes everyone to approve the work item, but only one dissenter to disapprove it.

Example:


var cd = getCorporateDirectory();
var user1 = cd.getUserById( "user1" );
var user2 = cd.getUserById( "user2" );
var user3 = cd.getUserById( "user3" );
var approvers = new Array( user1, user2, user3);
toParallelApproval( approvers, "trackerField" );
toParallelApproval(toGroup( "approvers" ), "trackerField" );

toUserById

toUserById(userId)

This function returns an array containing the user ID of the user with the given user ID. This function is intended to be used as an assignment script but can be used anywhere that an array of user IDs is needed.

  • userId

String of a user ID.

Example:


var userArray = toUserById( "sijacic" );

toUserFromField

toUserFromField(dataField)

This function returns an array containing the user IDs of the user whose user ID is the value of the given data field. This function is intended to be used as an assignment script but can be used anywhere that an array of user IDs is needed.

dataField

String of a name of a data field whose value is a user ID.

Example:


var userArray = toUserFromField( "approver" );
var approver = userArray[0];

Miscellaneous Global Functions

This section summarizes the global functions that are neither log and error functions nor predefined scripts.

The global functions in this section are:

ejbLookup

ejbLookup(jndiName)

Looks up an EJB that can be found under the given JNDI name. If no EJB exists under this name, an EJB exception, javax.naming.NamingException, is thrown. Process Manager handles this exception by moving the process instance into the designated Exception Manager node.

If the bean can be found under the given JNDI name, the home interface of that bean is returned. The home interface is used to create new instance of the EJB or find existing instances of the given EJB. The definition of the home interface is completely application-dependent; it typically consists of several create() and finder() methods. This function call is equivalent to the getJndiNamingContext().lookup(jndiName) function call.

  • jndiName

A String of the JNDI name of the EJB to look up.

Example:


var home = ejbLookup("iPlanet/CreditCardServer");
// Create a credit card server that can do card authorizations.
var creditCardServer = home.create ( "mastercard" );

evaluateTemplate

evaluateTemplate(templateName)

Used primarily in email notifications, but can be used for any template-like evaluation.

For email notifications, use evaluateTemplate() in the email body. When you create an email notification in Process Builder, specify evaluateTemplate( "templateFile" ) as the body script, where templateFile is the name of the template file relative to the application directory on the server.

Include your template files in the following directory on the local machine where Process Builder resides: <iPM_install_directory>/builder/Applications/<your_app>/templates. When you deploy your application, the same directory structure is replicated on the application server.

evaluateTemplate() also evaluates JavaScript segments contained in the template file. These segments are identified by <script language="Rhino"> tags.

In an HTML page containing client-side JavaScript, you can replace

<script language="JavaScript">

with

<script language="Rhino">

The Process Manager engine will evaluate the JavaScript in the same manner the browser does.

You can access the entire engine API (e.g., getProcessInstance(), getWorkITem(), etc.) from within these segments. To send output to an HTML file, use document.write() with the output you want to send provided as an argument.

evaluateTemplate() returns a string. The string is made up of the contents of the template file with the Rhino segments evaluated. If there are no Rhino segments in the file, the string simply contains the file contents. If there are Rhino segments, the string contains the evaluated JavaScript rather than the Rhino segments.

Example:


var fileContents = evaluateTemplate( "templateFile" );
var cs = getContentStore():
cs.upload( fileContents, url ):

expireIn

expireIn(val, unit)

Returns a JavaScript Date object set to the absolute datetime when the current work item expires.

  • val

An Integer specifying the number of units in which to expire the workitem.

  • unit

A String that specifies the unit of time measurement, such as minutes or hours.

This function is normally used to specify the expiration time for a particular activity, and is usually set by the designer through Process Builder. In the event that you choose to specify the arguments for this function manually, the parameter unit can contain the following values:

  • minutes
  • hours
  • days
  • weeks
  • months

Note that a month is presumed to contain 30 days. Asking a work item to expire one month from the date January 1st results in an expiration date of January 30th, not February 1st.

Example:


expireIn( 6, "minutes" );    // expire in 6 minutes
expireIn( 30, "days" );     // expire in 30 days
expireIn( 1, "month" );     // expire in 30 days

getAction

getAction()

Returns the name of a transition (button). Examples of possible return values for getAction are "deny" or "approve".

The transition corresponds to the name of the button clicked when a work item form is submitted. This function can be used in any script, but is best used from the completion script of a user activity.

Example:


function completion( )
{
   var pi = getProcessInstance();
   pi.setData( "submittedAction", getAction() ):
   return true;
}


getApplicationName

getApplicationName()

Returns the name of the application (for example: "DataSheet") as a string.

Example:


var appName = getApplicationName();

getApplicationPath

getApplicationPath()

Returns the pathname of the directory containing the files for this application as a string.

Example:


var appPath = getApplicationPath();

getApplicationPrettyName

getApplicationPrettyName()

Returns the pretty name of the application (for example: "DataSheet Management") as a string.

Example:


var appPN = getApplicationPrettyName();

getBaseForFileName

getBaseForFileName (processId)

Given a unique process instance ID, this function returns a string of the base file name for the content store for that process instance.

  • processId

A String of the process instance ID.

The following code creates a path name for the file myFile.html in the content store. Note that this code does NOT create the file, it simply creates a string that can be used as the file name by methods on a contentStore object, such as move() and store().

Example:


var pi = getProcessInstance();
var pid = pi.getInstanceId();
var contentStorePath = getBaseForFileName (pid);
var newFileName = contentStorePath + "myFile.html";

getConnector

getConnector(connectorKey)

Given a connector key, returns a connector object from the list of connector objects available for use by scripts.

  • connectorKey

A String specifying a connector ID (previously set by setConnector()).

Example:


function initialisationScript( )
{
   var c = new Packages.com.acme.DBConnection();
   setConnector( "dbConnector" );
   return true;
}
var c = getConnector( "dbConnector" );

getContentStore ()

getContentStore ()

getContentStore(httpURL,user,password)

Returns a contentStore object connected to the content store. If no arguments are passed, this method gets the content store associated with the current application.

If httpURL, user and password arguments are provided, this method returns a content store object connected to the given URL.

You must have a content store object to use any of the content store methods.

  • httpURL

A String of the URL of an HTTP server capable of acting as a content store.

  • user

A String of the User ID of the user who will authenticate the content store specified by httpURL.

  • password

Password for the specified user.

Example:


var cs = getContentStore();

var publishCS = getContentStore(
"http://publish.iplanet.com/CS", "sijacic", "password");


getCreatorUserId

getCreatorUserId ()

Returns the user ID for the creator user of the current process instance.

This function is intended to be used as the initiate-as script for sub-process nodes. When the child process instance is created, its creator must be determined. Normally, the creator of the child process instance is the same user that authenticated with the server at the time the sub-process node was executed. However, it may be desirable (or necessary) to set the child creator to the same user as the creator of the parent process instance.

If you choose to use this function to change the child creator user, the authenticating (or current) user must be a member of the trusted users group in the child application.

Example:


var pi = getProcessInstance();
var creatorUser = pi.getCreatorUser();
var creatorUserId = creatorUser.getUserId();

getCorporateDirectory

getCorporateDirectory ()

Returns a corporateDirectory object connected to the corporate directory in the Directory Server. See the section "CorporateDirectory" for details of the methods on this object.

Example:

var corpDir = getCorporateDirectory();

__getIncludePath

__getIncludePath ()

Returns the current inclusion path used by the server to search for JavaScript source files. This search path resembles in behavior the PATH mechanism used in Windows NT and UNIX to search for executables and libraries when a file name is not absolute.

The directory installDir/resources/server/js (where installDir is Process Manager installation directory on the server machine) is included in the search path by default.

Example:


// Returns the current search path
var includePath = __getIncludePath();

// Add our own directory to the search path
includePath += ';' + "d:\\tmp";

// Set the search path
__setIncludePath( includePath );


getJndiNamingContext

getJndiNamingContext()

Returns the current iAS JNDI naming context used to look up the home interface of an EJB.

Use this function to access EJBs from within a Custom Activity. You can pass the instance of the naming context to the Custom Activity and use the lookup() method on this context to obtain home interfaces of the beans.

Example:

var namingContext = getJndiNamingContext()

getProcessInstance

getProcessInstance ()

Returns a JavaScript ProcessInstance object associated with the current work item.

See the section ProcessInstance for details of the methods on this object.

Example:


var wi = getWorkItem();
var pi = getProcessInstance();
var pid = pi.getInstanceId();

getSubProcessInstance

getSubProcessInstance ()

Returns a ProcessInstance object corresponding to the completed child process instance. This function should only be used from the completion script of a sub-process node. The object returned by this function has all the same methods expected of a ProcessInstance object, except that the information contained within corresponds to the completed child process instance instead of the parent. If this function is called from any location other than the completion script of a sub-process node, null is returned.

Example:


// Completion script of sub-process node
function parentCompletion( )
{
var pi = getProcessInstance();        // parent process instance
var spi = getSubProcessInstance();    // child process instance

// Map some of the data elements from the child back to the
// parent process instance
pi.setData( "childStatus", spi.getData( "status" ) );
pi.setData( "numApprovers", spi.getData( "numApprovers" ) );
return true;
}

getWorkItem

getWorkItem ()

Returns a workItem object that represents the current work item. See the section WorkItem for details of the methods on this object.

Example:

var wi = getWorkItem();

__includeFile

__includeFile (fileName)

Reads in the contents of a JavaScript source file and evaluates the contents. Any JavaScript functions and objects defined within the file are available to all user scripts.

The function __includeFile() and its "helper" functions, __getIncludePath() and __setIncludePath(), are used by the server to define the built-in JavaScript functions available to user scripts.

If you want to access JavaScript functions or objects from user scripts and do not want to include the script files with every application you develop, you can externalize the functions in a separate JavaScript file and include the functions in the server's global run-time scope using __includeFile().

  • fileName

A String of the pathname of the JavaScript file to evaluate.

Example 1:


// Sample JavaScript file
function checkCreator( userId )
{
   var pi = getProcessInstance();
   var u = pi.getCreatorUser();

   // If the process instance creator matches the
   // userId, return true, else false.
   if( userId == u.getUserId() )
         return true;
   else
         return false;
}


Example 2


// Sample includeList.js file
var myIncludePath = "d:\\tmp";
var includePath = __getIncludePath() + ';' + myIncludePath;

__setIncludePath( includePath );
__includeFile( "myFunctions.js" );


mapTo

mapTo(fieldName)

Used only from a custom activity as a means of mapping values from the output hashtable back to the process instance. The fieldName parameter specifies the name of a data element in the process instance. This data element receives the value of the current output parameter. When the custom activity's perform() call is complete, the server iterates through the hashtable, one element at a time, and attempts to map the element's value to a field in the process instance. Returns true if data mapping succeeds. Returns false if a problem has occurred.

  • fieldName

A String of the name of a data element in the process instance.

Example:

mapTo( "customerName" );

mount

mount(jndiName)

Looks up and creates an instance of a stateless session bean, or EJB, found under the given JNDI name. If no bean exists under this name, a javax.naming.NamingException is thrown. Process Manager handles this exception by moving the process instance into the designated Exception Manager node. If the EJB can be found under the given JNDI name, you create an instance of it by calling the create() method on the returned home interface of the bean. This function call is equivalent to the ejbLookup(jndiName).create() function call.

  • jndiName

A String of the JNDI name of the EJB to "mount."

Example:

var creditServer = mount("iPlanet/CreditCardServer");

setConnector

setConnector(connKey, connObject)

Adds a connector object (such as a database connection) indexed by key to the list of connector objects that can be used by scripts.

  • connKey

A String of the key used to retrieve the associated object (through getConnector()).

  • connObject

Object stored and associated with the specified key.

JavaScript objects saved inside the Connector, such as those created using var obj = new Object ( ), are converted into Java objects based on the mapping table below before being stored in the connector

JavaScript Data Type

Converted Java Data Type

  • string

java.lang.String

  • number

java.lang.Double

  • boolean

java.lang.Boolean

  • date

java.util.Date

  • array

java.lang.Object[]

  • object

java.util.Hashtable

  • function

java.lang.String (decompiled source)

  • script

java.lang.String (decompiled source)

  • java.lang.Object (wrapped)

java.lang.Object (unwrapped)

  • java.lang.Object

java.lang.Object (pass-through)

Example:


function initialisationScript( )
{
var c = new Packages.com.acme.DBConnection();
setConnector( "dbConnector", c );
return true;
}

// This DB connection can now be used in any script.
var c = getConnector( "dbConnector" );

__setIncludePath

__setIncludePath (includePath)

Allows the user to specify the path the server uses to search for JavaScript source files. The path is a delimited list of absolute directory path names. The delimiter depends upon the system:

  • : (a colon) for UNIX
  • ; (a semicolon) for Windows

Searches start from the first directory and proceed to the last directory until the file is located. The directory installDir/resources/server/js (where installDir is where Process Manager is installed on the server machine) is included in the search path by default. However, once you set your own path using this function, the current search path is overwritten. Thus, calls to __setIncludePath should specify the entire search path by appending the new search directory to the current search path.

includePath

A String of the search path the server uses to locate JavaScript source files.

Example:


var includePath = __getIncludePath();
includePath += ';' + "d:\\tmp";

// Set the search path. Note how the variable includePath also
// specifies the existing search path.
// Every call to __setIncludePath
// overwrites the previous search path.
__setIncludePath( includePath );


setRedirectionURL

setRedirectionURL(stringURL)

Redirects the participant's browser to the specified location in stringURL.

Invoke this method from a completion script so that when the activity has completed, the user immediately sees another HTML page such as a form rather than the standard activity completion dialog box.

The setRedirectionURL() method is typically used for multiple-screen data entry where the same person is required to enter data across several screens of user activities. The process subsequently becomes a wizard-like forms entry screen.

  • stringURL

A String of a valid URL.

Example:


function scriptComplete( )
{
   // Redirect to the Sun Home Page
   setRedirectionURL( "http://www.sun.com" );

   // Alternatively, this causes the next work item in the same
   // process instance to be displayed after
   // the user clicks an action button
   setRedirectionURL( url_OnDisplayProcessInstance() );

   // Don't forget to return true;
   // this is still a completion script
   return true;
}


url_OnDisplayHistory

url_OnDisplayHistory()

Returns a string containing the URL that points to the history list for the current process instance. This function is usually used in conjunction with setRedirectionURL() to redirect a user to the history page of the current process instance.

Example:


function scriptComplete( ) {
// Redirect to the History Page of this process instance
setRedirectionURL( url_OnDisplayHistory() );
// Don't forget to return true;
// this is still a completion script
return true;

}

url_OnDisplayProcessInstance

url_OnDisplayProcessInstance()

Returns a string containing the URL that points the current process instance. This function is usually used in conjunction with setRedirectionURL() to redirect a user to the current process instance.

Example:


function scriptComplete( )
{
// Redirect to the current process instance
setRedirectionURL( url_OnDisplayProcessInstance() );
// Don't forget to return true;
// this is still a completion script
return true;

}


url_OnDisplayWorklist

url_OnDisplayWorklist()

url_OnDisplayWorklist()

Returns a string containing the URL that points to the user's work list. This function is usually used in conjunction with setRedirectionURL() to redirect a user to their work list.

Example:


function scriptComplete( )
{
// Redirect to the user to their work list
setRedirectionURL( url_OnDisplayWorklist() );
// Don't forget to return true;
// this is still a completion script
return true;

}


url_OnListApplications

url_OnListApplications()

Returns a string containing the URL listing applications installed on the Process Manager cluster. This function is usually used in conjunction with setRedirectionURL() to redirect a user to the list of applications installed on the cluster.

Example:


function scriptComplete( )
{
// Redirect to the list of applications on this cluster
setRedirectionURL( url_OnListApplications() );
// Don't forget to return true;
// this is still a completion script
return true;

}


url_OnListEntryNodes

url_OnListEntryNodes()

Returns a string containing the URL that points to the list of entry points in the current application. This function is usually used in conjunction with setRedirectionURL() to redirect a user to the list of entry points in the current application.

Example:


function scriptComplete( )
{
// Redirect to the list of entry points of the current application
setRedirectionURL( url_OnListEntryNodes() );
// Don't forget to return true;
// this is still a completion script
return true;

}


Alphabetical Summary of JavaScript Methods and Functions

The following table lists the JavaScript methods and functions available in Process Manager:

JavaScript Method or Function

Where Used in Process Manager

__getIncludePath

 

global function

 

__includeFile

 

global function

 

__setIncludePath

 

global function

 

addGroupAssignee

 

workItem

 

addUser

 

corporateDirectory

 

addUserAssignee

 

workItem

 

assignees

 

workItem

 

checkParallelApproval

 

predefined script

 

copy

 

contentStore

 

defaultNotificationHeader

 

predefined script

 

defaultNotificationSubject

 

predefined script

 

deleteUserByCN

 

corporateDirectory

 

deleteUserByDN

 

corporateDirectory

 

deleteUserById

 

corporateDirectory

 

download

 

contentStore

 

ejbLookup

 

global function

 

emailById

 

predefined script

 

emailOfAssignees

 

predefined script

 

emailOfCreator

 

predefined script

 

emailOfRole

 

predefined script

 

evaluateTemplate

 

global function

 

exists

 

contentStore

 

expireIn

 

global function

 

extend

 

workItem

 

getAction

 

workItem

 

getApplicationName

 

global function

 

getApplicationPath

 

global function

 

getApplicationPrettyName

 

global function

 

getBaseForFileName

 

global function

 

getBaseURL

 

global function

 

getConnector

 

global function

 

getContent

 

contentStore

 

getContentStore ()

 

global function

 

getCorporateDirectory

 

global function

 

getCreationDate

 

processInstance

 

getCreationDate

 

workItem

 

getCreatorUser

 

processInstance

 

getCreatorUserId

 

global function

 

getData

 

processInstance

 

getEntityKey

 

processInstance

 

getEntryNodeName

 

processInstance

 

getException

 

contentStore

 

getExitNodeName

 

processInstance

 

getExpirationDate

 

workItem

 

getInstanceId

 

processInstance

 

getJndiNamingContext

 

processInstance

 

getNodeName

 

workItem

 

getPriority

 

global function

 

getProcessInstance

 

processInstance

 

getRoleUser

 

contentStore

 

getRootURL

 

contentStore

 

getSize

 

contentStore

 

getStatus

 

contentStore

 

getSubProcessInstance

 

global function

 

getTitle

 

processInstance

 

getUserByCN

 

corporateDirectory

 

getUserByDN

 

corporateDirectory

 

getUserById

 

corporateDirectory

 

getUserId

 

user

 

getVersion

 

contentStore

 

getWorkItem

 

global function

 

hasExpired

 

workItem

 

initialize

 

contentStore

 

isException

 

contentStore

 

isStateActive

 

workItem

 

isStateRunning

 

workItem

 

isStateSuspended

 

workItem

 

list

 

contentStore

 

logErrorMsg

 

global function

 

logHistoryMsg

 

global function

 

logInfoMsg

 

global function

 

logSecurityMsg

 

global function

 

mapTo

 

global function

 

mkdir

 

contentStore

 

modifyUserByCN

 

corporateDirectory

 

modifyUserByDN

 

corporateDirectory

 

modifyUserById

 

corporateDirectory

 

mount

 

global function

 

move

 

contentStore

 

moveTo

 

workItem

 

randomToGroup

 

predefined script

 

remove

 

contentStore

 

removeAssignees

 

workItem

 

resume

 

workItem

 

rmdir

 

contentStore

 

setConnector

 

global function

 

setData

 

processInstance

 

setEntityKey

 

global function

 

setExpirationDate

 

workItem

 

setRedirectionURL

 

global function

 

setRoleById

 

processInstance

 

store

 

contentStore

 

suspend

 

workItem

 

toCreator

 

predefined script

 

toGroup

 

predefined script

 

toManagerOf

 

predefined script

 

toManagerOfCreator

 

predefined script

 

toManagerOfRole

 

predefined script

 

toParallelApproval

 

predefined script

 

toUserById

 

predefined script

 

toUserFromField

 

predefined script

 

upload

 

contentStore

 

url_OnDisplayHistory

 

global function

 

url_OnDisplayProcessInstance

 

global function

 

url_OnDisplayWorklist

 

global function

 

url_OnListApplications

 

global function

 

url_OnListEntryNodes

 

global function

 


Previous      Contents     Index      Next     
Copyright 2002 Sun Microsystems, Inc. All rights reserved.


816-6354-10