Events

During an ALM Web Client user session, as the user initiates various actions, ALM Web Client triggers events. You can place code in these events to customize the execution of the associated user actions.

The following table describes when each event is triggered and what you can achieve by editing the event:

Event Description
New

This event is triggered when an entity is added to Web Client.

You can add code to this event procedure to perform an action when a new object is added.

Syntax: <entity>_New

For examples, see Example: Add a template to a memo field.

MoveTo

This event is triggered when the user changes focus from one object to another.

You can add code to this event procedure to perform actions when the user changes the focus.

Syntax: <entity>_MoveTo

For examples, see Example: Present a dynamic field list.

FieldCanChange

This event is triggered before Web Client changes a field value, to determine whether the field can be changed.

You can add code to this event procedure to prevent a field from being changed in specific cases.

Syntax: <entity>_FieldCanChange(fieldName, newValue)

where fieldName is the name of the field。

newValue is the filed value.

For examples, see Example: Validate a field.

FieldChange

This event is triggered when the value of the specified field changes.

Every change of value triggers the field change event when the field loses focus.

You can add code to this event procedure to perform an action when the value of a particular field is changed.

Syntax:  <entity>_FieldChange(fieldName)

where fieldName is the name of the filed.

For examples, see Example: Change one field based on another field.

CanPost

This event is triggered before Web Client updates an entity, to check whether the entity can be updated.

You can add code to this event procedure to prevent an entity from being updated in specific cases.

Syntax: <entity>_CanPost

For examples, see Example: Validate if an entity can be updated in specific cases.

CanDelete

This event is triggered before Web Client deletes an entity, to check if the entity can be deleted.

Syntax: <entity>_CanDelete(Entity)

AfterPost

This event is triggered after an entity has been updated in Web Client.

Project fields should not be changed after they have been posted, because then the new value is not stored in the database.

Syntax:<entity>_AfterPost

CanAddTests

This event is triggered before Web Client adds tests to a test set, to check whether the specified tests can be added.

Syntax: TestSet_CanAddTests(Tests)

where Tests is an array of test IDs.

CanRemoveTests

This event is triggered before Web Client removes tests from a test set, to check whether the specified tests can be removed.

Syntax: TestSet_CanRemoveTests(Tests)

where Tests is an array of test IDs.

DefaultResult

This event is used to determine the default return value for ALM events, such as FieldCanChange.

All ALM events call this event (unless explicitly omitted by user) to determine the default return value. DefaultResult can be used to quickly replace the default return values of all ALM events.

Available in: Common script node

Syntax: DefaltResult

CanLogin

This event is triggered to check whether the specified user can log in to the specified project.

Available in: Common script node

Syntax: CanLogin(domainName, projectName, userName)

where domainName is the domain name.

projectName is the project name.

userName is the user name.

GetDetailsPageName

This event is triggered by Web Client to retrieve the name of the page (tab) that has the index number specified in PageNum in the following dialog boxes:

  • The Details dialog box for an entity

  • The New <entity> dialog box for an entity

You can add code to this event to customize the tab names for the Details dialog box.

Available in: Common script node

Syntax: GetDetailsPageName(pageName, pageNum)

where pageName is the default page (tab) name (for example, Page 1).

pageNum is the page (tab) number.

For examples, see Example: Change tab names of entity details dialog box.

ActionCanExecute

This event is triggered before Web Client performs an action that has been initiated by the user, to check whether the action can be executed.

You can add code to this event procedure to perform actions when the user has initiated a particular action, or to prevent the action from being executed in specific cases.

Available in: Common script node

Syntax: ActionCanExecute(actionName)

where actionName is the action that the user has initiated.

An action name is in the format of context.action. For example, Defect.DeleteDefect.

Important: You can use the ActionCanExecute event for main entity actions only. For details about supported actions, see Supported actions.

For examples, see Example: Prevent users from performing an action.

SharedFunction

You can define global constants or functions in the SharedFunction event.

  • Scripts included in the <module>_SharedFunction events can be used by any other event in the same module.

  • Scripts included in the Common scripts node > SharedFunction event can be used by events in any module.

If a script calls the SharedFunction event and changes the constants or variables of this event, the changes take effect only in this script and only in the current execution.

For examples, see Example: Customize fields in New Defect dialog box.