9.3 User Application API

This section includes information on the following topics:

9.3.1 Form Action Script Methods

Unlike the ECMAScript that runs in other components of the workflow, form script executes on the Web browser, not the server. All directory access from within form script is handled by AJAX calls from the browser to the server.

This section lists all form action methods and properties supported by the ECMA Expression Builder.

Form

Lets you work with Form methods.

focus(fieldname)
form.focus(fieldname)

Sets the focus to the specified field. For list-based or choice-based controls, sets the focus to either the selected choice or when no selection is made, it sets the focus to the first choice. If a fieldname parameter is passed and that field is list or choice based, it sets the focus on the choices corresponding to the values parameter. If the value is an array, only the first value is used to determine on which check box or radio button to set focus. If the specified field is invisible or disabled, this method has no effect.

select(fieldname)
form.select(fieldname)

If no values parameter is passed in, this method sets the focus to the underlying text field. For list-based or choice-based controls, this method sets the focus to the selected choice or if no selection was made, to the first choice. If a values parameter is passed and the field is list-based or choice-based it sets the focus on the choices corresponding to the fieldname parameter. This method has no effect on disabled or invisible fields.

activate(fieldname)
form.activate(fieldname)

A combination of setFocus() and select().

setRequired(fieldname, is-required)
form.setRequired("fieldname", is-required)

Sets the field to required if is-required is True; otherwise, the field is optional. A field that is required blocks the form submission if the field is empty.

InterceptAction(actionname, order, function)
form.interceptAction("actionname", "order", "function")

Allows you to intercept the script attached to an action button. The function passed in is executed based on the order parameter.

Valid actionname values are SubmitAction and CancelAction.

The choices for actionname for an approval form are: ApprovalAction, RefusalAction, DenyAction, UpdateAction, CancelAction and CommentAction.Valid values for the advice parameter are:Before: The function is called before the script attached to the button executes.after: The function is called after the script attached to the button executes.around: The function is passed a parameter that allows you to decide whether to execute the script attached to the button The following example shows the submit action intercepted. The form is only submitted if the user replies Yes.

window.inv=function (invocation) { if (confirm( "Are you sure you want to submit ?")) { var result = invocation.proceed(); return result; }; };
form.interceptAction("SubmitAction", "around", window.inv);
getLocale()
form.getLocale()

Returns the current locale. Can be used as input for all methods that support a locale parameter.

getRBMessage()
form.getRBMessage(key)
form.getRBMessage(key, value[s])
form.getRBMessage(key, value[s], bundle)

This method tries to find an entry with key in the resource bundle with ID bId. The resourcebundle Java class should extend the java.util.ListResourceBundle.Parameter. The parameter can be used to pass in replacements for parameters ({0}, {1}, etc) in message "msg"; for example:

var msg = frm.getRBMessage ("mykey", ["value0", "value1"], "mybundle");
stringToDate()
form.stringToDate(date)
form.stringToDate(date, include-time)

Converts a date string to a Date. The format must correspond to the dateform for the current locale, as used in the DatePicker. The value of a DatePicker control can be converted with this method. Example:

form.showMsg("Date="+form.stringToDate(d,true));
dateToString()
form.dateToString(date)
form.dateToString(date, include-time)

Converts a date to a string that can be stored in the DatePicker, for example:

var d = form.dateToString(new Date(), true); 
form.setValues("hireDate", d);
isValidDate(date)
form.isValidDate(date)

Use this to validate the correct format for a date string.

isValidDate(date,include-time)
form.isValidDate(date, include-time)

Use this to validate the correct format for a date string.

alert(string)
form.alert("msg")

Displays a message in an alert box.

showMsg(string)
form.showMsg(msg, param, bId)

Adds a message to the status portion of the form. The msg string parameter can either contain the text of the message itself or it can contain a key pointing to an entry in the resource bundle bId. This method always tries to find an entry with the key msg in the resource bundle with the id bId.The param parameter can be used to pass in replacements for stakeholders ({0}, {1}, etc) in msg.

NOTE:If you want to add debugging messages to your script, it is better practice to use form.showDebugMsg().

Example:

form.showMsg("my message" {0},{1}", ["value0","value1"]);
showWarning(string)
form.showWarning(msg, param, bId)

Adds a warning to the status portion of the form.

The msg string parameter can either contain the text of the warning itself or it can contain a key pointing to an entry in the resource bundle bId. This method always tries to find an entry with the key msg in the resource bundle with the id bId. The param parameter can be used to pass in replacements for stakeholders ({0}, {1}, etc) in msg.

NOTE:If you want to add debugging messages to your script, it is better practice to use form.showDebugMsg() .

Example:

form.showWarning("my warning" {0},{1}", ["value0","value1"]);
showError(string)

showError(msg, param, bId);

Adds an error message to the status portion of the form.

The msg string parameter can either contain the text of the error itself or it can contain a key pointing to an entry in the resource bundle bId. This method always tries to find an entry with the key msg in the resource bundle with the id bId. The param parameter can be used to pass in replacements for stakeholders ({0}, {1}, etc) in msg.

NOTE:If you want to add debugging messages to your script, it is better practice to use form.showDebugMsg() .

Both normal and fatal errors block form submission. The distinction between a normal error and a fatal error is that normal errors get reset just before form validation occurs (because of a form submission). Fatal errors are remembered and therefore block the form submission unless you restart. A normal error only blocks submission if it is generated during the validation phase. If you add normal errors during onload or custom events, they are lost when the form is submitted.

NOTE:If you want to add debugging messages to your script, it is better practice to use form.showDebugMsg().

Example:

form.showError("my error" {0},{1}", ["value0","value1"]);
showFatal(string)

form.showFatal("my fatal" {0},{1}", ["value0","value1"]);

Adds a fatal error message to the status portion of the form.

The msg string parameter can either contain the text of the fatal error itself or it can contain a key pointing to an entry in the resource bundle bId. This method always tries to find an entry with the key msg in the resource bundle with the id bId. The param parameter can be used to pass in replacements for stakeholders ({0}, {1}, etc) in msg.

Both normal and fatal errors block form submission. The distinction between a normal error and a fatal error is that normal errors get reset just before form validation occurs (because of a form submission). Fatal errors are remembered and therefore block the form submission unless you restart. A normal error only blocks submission if it is generated during the validation phase. If you add normal errors during onload or custom events, they are lost when the form is submitted.

NOTE:If you want to add debugging messages to your script, it is better practice to use form.showDebugMsg().

Example:

form.showFatal("my fatal" {0},{1}", ["value0","value1"]);
enable(fieldname)
form.enable("fieldname")

Enables a field on a form.

disable(fieldname)
form.disable("fieldname")

Disables a field on a form.

NOTE:A disabled field still sends data back to the workflow engine. The content of a disabled field is validated when submitting the form or when calling the field.validate() method.

getValue(fieldname)
form.getValue("fieldname")

Returns the first value for the field. The type returned is always string, independent of the data type of the field. If the field does not have a value, the method returns an empty string if text can be entered into the field (like Text, TextArea, DatePicker, DNLookup) or it returns “undefined” if the control is choice-based (for example, StaticList, radio buttons, check boxes). For DN type controls, this method always returns the DN and never the display expression.

getValues(fieldname)
form.getValues("fieldname")

Returns a string array containing the values. If no values are found, the array is empty (size = 0). For DN type controls, this method always returns the DN and never the display expression.

setValues(fieldname)
form.setValues("fieldname", data-values, display values, KeepOldValues)

Sets a value. Supports multiple values. This method allows changing the available entries for list-based controls (for example, StaticList, MVCheckbox, PickList). By default, existing values are deleted unless the KeepOldValues parameter equals True. For non-list-based controls, the display values parameter is ignored.

Field

Lets you work with Field methods.

activate()
field.activate(value[s])

This method is a combination of field.focus() and field.select().

disable()
field.disable()

Disable the field.

NOTE:A disabled field still sends data back to the workflow engine. The content of a disabled field is validated when submitting the form or when calling the field.

enable()
field.enable()

Enable the field.

fireEvent()
field.fireEvent("eventname")

Fires a custom event. Passes the name of the custom event that is fired. To get the values of the event that is fired, use form.getValues(event.getOrigin()).

focus()
field.focus(value[s])

If no values parameter is passed in, this method sets the focus to the underlying text field. For list-based or choice-based controls, this method sets the focus to the selected choice if no selection was done to the first choice. If a values parameter is passed and if the field is list-based or choice-based, this method sets the focus on the choices corresponding to the values parameter. If the values parameter is an array, only the first value is used to determine the check box or radio button to set focus. This method has no effect on disabled or invisible fields.

getLabel()
field.getLabel()

Gets the label associated with the field. If no label is found, this method returns the name of the field.

getName()
field.getName()

Gets the name of the field.

getValue()
field.getValue()

Returns the first value for the field. The type returned is always a string, independent of the data type of the field. If the field does not have a value, the method returns an empty string if text can be entered into the field (like Text, TextArea, DatePicker, DNLookup) or it returns “undefined” if the control is choice-based (for example, StaticList, radio buttons, check boxes). For DN type controls, this method always returns the DN and never the display expression.

hide()
field.hide()

Hides this field.

getValues()
form.getValues()

Returns a string array containing the requested values. If no values are found, the array is empty (size = 0). For DN type controls, this method always returns the DN and never the display expression.

show()
field.show()

Shows this field.

select()
field.select(value[s])

If no values parameter is passed in, this method sets the focus to the underlying text field. For list-based or choice-based controls, it sets the focus to either the selected choice or if no selection was made, it sets the focus to the first choice. If a values parameter is passed and if the field is list-based or choice-based, it sets the focus on the choices corresponding to the values parameter. If the value parameter is an array, only the first value is used to determine which check box or radio button to set focus on. This method has no effect on disabled or invisible fields.

setRequired()
field.setRequired(is-required)

Sets the field to required if isRequired is True or optional otherwise. A field that is required blocks the form submission if it is empty.

setValues(fieldname)
field.setValues(data-values, display-values, KeepOldValues)

Sets a value. Supports multiple values. This method allows changing the available entries for list-based controls (for example, StaticList, MVCheckbox, PickList). By default, existing values are deleted unless the KeepOldValues parameter equals True. For non-list-based controls, the display values parameter is ignored.

If you want to set or change the initial value of a field, you should do so in an onload event.

NOTE:This method triggers the onchange event for the field.

Examples:

field.setValues("cn=jdoe,ou=users,ou=mysample,o=novell"); // for a DNLookup
field.setValues(["jdoe@novell.com", "test@novell.com"]) // for an MVEditor
field.setValues(["W","B"],["White","Black"],true); // for a StaticList
validate()
field.validate()

Triggers browser validation for the field. To validate the data entered in this field as soon as the user navigates to another field, call this method in the onchange event. Returns True if validation errors were detected; otherwise, returns False..

Event

Lets you work with events. This section includes the following methods:

getEventName()
event.getEventName()

Returns the name of the event.

getOrigin()
event.getOrigin()

Returns the name of the field from which the event was triggered.

getValue()
event.getValue()

Returns a string that contains the first value in the event.

You should not use the value that is returned by this method, because it is possible that a user might have modified the data in the field after the event was triggered. Instead, you should use the value returned by the form.getValue method. For example, form.getValue(event.GetOrigin()). This ensures that you get the current value of the field. If you select event.getValue() from the pick list in the ECMA Expression Builder, form.getValue(event.GetOrigin()) is inserted.

getValues()
event.getValues()

Returns an array of strings that contains all values in the event.

You should not use the value that is returned by this method, because it is possible that a user might have modified the data in the field since the event was triggered. Instead, you should use the value returned by the form.getValues method. For example, form.getValue(event.GetOrigin()). This ensures that you get the current value of the field. If you select event.getValues() from the pick list in the ECMA Expression Builder, form.getValues(event.GetOrigin()) is inserted.

Lists

Lets you work with lists.

globalList(fieldname, key, locale)
IDVault.globalList("fieldname", "key", "locale")

Retrieves a global list from the directory abstraction layer, identified by the key of the global list. If the field name is specified, the result of the query is used to refresh the content of the field. To retrieve a list without storing the result in a field, use a null value for the fieldname parameter.The locale is optional. If locale is not specified, the locale in the HTTP request is used.

Example:

IDVault.globalList("dallist", "departments", "en");

Queries

Lets you work with queries.

globalQuery(fieldname, key, param)
globalQuery(fieldname, key, param)

Executes the predefined directory abstraction layer query key (see Queries General Properties). If the field name is specified, the result of the query is used to refresh the content of the field. To retrieve a list without storing the result in a field, use a null value for the fieldname parameter.The param parameter is used as input to the query. The parameter has the form {parname1:value,parname2:value}, in which the value can be an individual value or an array. The first column of the result list (always a DN) is used for the data value, and the second column is used for the display label.

Example:

IDVault.globalQuery("canchangepwd", "getsites");  // query without a parameter
IDVault.globalQuery("building", "getbuildings", {site:form.getValue("site")}); // query with one parameter
IDVault.globalQuery("room", "getrooms", {site:form.getValue("site"), building:form.getValue("building")}); // query with two parameters

Container

Lets you work with containers.

containers(fieldname, rootdn, Search scope, Show DN)
IDVault.containers("test", rootdn, SearchScope, ShowDN)

Gets a list of containers, with the scope equal to “subtree” or the same level. The method returns an array with two entries, the first an array with the resulting DNs; the second entry an array with the display labels.

Table 9-5 Container Parameters

Parameter

Description

fieldname

If the field name is specified, the result of the query is used to refresh the content of the field. To retrieve a list without storing the result in a field, use a null value for the fieldname parameter.

rootdn

If the rootdn parameter is empty, the root container for the default entity is used.

scope

If the scope parameter is empty, one-level is used. Valid choices for scope are “o” (onelevel) and “s” (subtree).

showdn

If the parameter showDN is true, the full DN is used for the display label. Otherwise the naming part (for example, ou, dc) is displayed.

Example:

IDVault.containers("assetProp2", null, "o", true);  // set the entries in a StaticList to all containers directly under the root DN of the default entity

9.3.2 IDVault Functions

This section lists functions that are used with IDVault data.

DNCompare

DNcompare(String dn1, String dn2)

Performs a case-insensitive comparison of DNs from the Identity Vault. Returns True if the DNs are the same.

A DN encapsulates a distinguished name (an LDAP name with context). The syntax of the DNs must conform to that specified in RFC 2253, which describes the String representation of DNs. The following DNs are all valid for use with DNCompare (and would return True if compared):

cn=jdoe,ou=users,ou=idmsample,o=acme
CN=jdoe,ou=users,ou=idmsample,o=acme
cn=JDOE,ou=users,ou=idmsample,o=acme

For more information about RFC 2253, see RFC 2353.

Example:

if ( IDVault.DNcompare(flowdata.get('Activity3/CardRequest/Candidate'),recipient )) true; else false ;

get()

get()
get(fieldname)
get(fieldname,dn)
get(fieldname,dn,entity-type)
get(fieldname,dn,entity-type,attribute)

This corresponds to the IDVault.get() function of the workflow script engine. Retrieves the values of the attribute for the given entity. The result is an array of values. If the field parameter is specified the result of the query result is used to refresh the content of the field. If not, the result is up to the form developer to use the result of the query. Example:

IDVault.get("assetProp",dn,"user","LastName");

execService()

IDVault.execService(service)
IDVault.execService(service, param)
IDVault.execService(service, param, locale)

Executes an AJAX service and the result is used to refresh the content of the field. The service must be registered in the UI control registry. The first column of the result list result is used for the display value, the second one for the data value. Example :

var r=IDVault.execService("dnlookup2",params);
var res=r?r["_data"]["raw"][dn]["value"]:"error encountered";
field.setValues("IDVault.execService(\"dnlookup2\") :"+res);

9.3.3 nrfRequest Properties and Methods

This section lists functions used with the nrfRequest object in Roles Based provisioning request definitions. It includes:

Role Request Properties

Table 9-6 Role Request Properties

Property

Code

Description

NEW_REQUEST

0

Set by the User Application on a newly created nrfRequest object.

SOD_APPROVAL_START_PENDING

2

The Role Service driver attempts to start the SoD workflow again. This is used for requests in the SOD_APPROVAL_START_SUSPENDED mode.

SOD_APPROVAL_START_SUSPENDED

3

Occurs when the Role Service driver is not able to start an SoD workflow. A driver task then resets these requests to SOD_WORKFLOW_START_PENDING to retry the starting of the workflow.

SOD_EXCEPTION_APPROVAL_PENDING

5

Set by the Role Service driver after successfully initiating an SoD exception workflow.

SOD_EXCEPTION_APPROVED

10

Set by the SoD exception workflow when the exception is approved.

APPROVAL_START_PENDING

12

The Role Service driver attempts to start the workflow. The request must be in APPROVAL_START_SUSPENDED mode.

APPROVAL_START_SUSPENDED

13

Occurs when the Role Service driver is not able to start the approval workflow. A driver task then resets these requests to APPROVAL_START_PENDING to try to start the workflow again.

APPROVAL_PENDING

15

Set by the Role Service driver after successful role assignment workflow.

APPROVED

20

Set by the role assignment workflow when the exception is approved.

ACTIVATION_TIME_PENDING

25

Set by the Role Service driver after obtaining all necessary approvals and the activation time has not yet been reached.

PROVISION

30

Set by the Role Service driver after all the necessary approvals have been approved and the role activation time has been reached.

PROVISIONED

50

Set by the Role Service driver after a role has been provisioned.

PROVISIONING_ERROR

80

Set by the Role Service driver when an error occurred during provisioning/deprovisioning

SOD_EXCEPTION_DENIED

90

Set by the SoD exception workflow when the exception is denied.

DENIED

95

Set by the role assignment workflow when the exception is approved.

CLEANUP

100

Set when nrfRequest workflow should be cleaned up (deleted). This is intended to be triggered by a batch process some configurable amount of time after the request has either been fulfilled or denied.

Role Request Is Methods

isAddOperation

Returns True if this is an add operaton. Occurs when the AddedDN is not null.

public boolean isAddOperation() throws ActivityException
isRemoveOperation

Returns True if this is a remove operation. Occurs when the RemovedDN is not null.

public boolean isRemoveOperation() throws ActivityException
isTargetDNaUserDN

Retursn True if the target DN is a user DN.

public boolean isTargetDNaUserDN() throws ActivityException
isTargetDNaRoleDN

Returns True if the target DN is a role DN

public boolean isTargetDNaRoleDN() throws ActivityException
isTargetDNaContainerDN

Returns True if the target DN is a container DN

public boolean isTargetDNaContainerDN() throws ActivityException
isTargetDNaGroupDN

Returns True if this is target DN is a group DN.

public boolean isTargetDNaGroupDN() throws ActivityException

Role Request Get Methods

getCN

Returns the CN.

public String getCn() throws ActivityException
getCategoryLocaleString

Returns the category type localized string.

public String getCategoryLocaleString() throws ActivityException
getCompletedWFEmailAddress

Gets the completed work flow e-mail address. This is a convenience method for the NrfRequest ECMA script object.

public String getCompletedWFEmailAddress() 
getCorrelationId

Returns the Correlation ID.

public String getCorrelationId() throws ActivityException
getDecisionDate

Returns the decision date.

public Date getDecisionDate() throws ActivityException
getDescription

Returns the description.

public String getDescription() throws ActivityException
getEndDate

Returns the end date.

public Date getEndDate() throws ActivityException
getEntityKey

Returns the entity key.

public String getEntityKey()
getLocale

Returns the preferred locale.

public Locale getLocale()
getOperation

Returns either the Add operation or the Remove operation.

 public String getOperation() throws ActivityException
getRequestDate

Returns the request date.

public Date getRequestDate() throws ActivityException
getRequester

Returns the requester.

public String getRequester() throws ActivityException
getStatusLocaleString

Returns the status localized string.

public String getStatusLocaleString() throws ActivityException
getStartDate

Returns the start date.

public Date getStartDate() throws ActivityException
getStatusValue

Returns the status int value.

public int getStatusValue() throws ActivityException
getSourceDN

Returns the source DN.

public String getSourceDN() throws ActivityException
getSourceDNDisplayName

Returns the source DN display name. This is a Role DN.

public String getSourceDNDisplayName() throws ActivityException 
getTargetDN

Returns the target DN affected by this operation.

public String getTargetDN() throws ActivityException
getTargetDNDisplayName

Returns the Target DN display name. If it is:

  • If it is a user, it returns first name + last name.

  • If it is a group, it returns the description.

  • If it is a role, it returns the description.

  • If it is a container, it returns the target DN.

 public String getTargetDNDisplayName() 
getCategoryValue

Returns the category type int value.

public int getCategoryValue() throws ActivityException