Common API calls

This topic lists the basic building blocks from which you can create hooks.

Each API call is shown first in VBScript and then in Perl. The syntax uses an <object.><method> format.

In Perl, the current Entity object and Session object are predefined as entity and session (lowercase). For VBScript, the current Entity object is assumed and you do not need to explicitly identify it when calling its methods.

For more information, see the Compass API Reference.

API Call (VBScript/Perl)
Function
[entity.]GetSession $entity->GetSession
Gets the session, which is necessary to invoke many other APIs.
session.OutputDebugString $session->OutputDebugString
Outputs to the debug stream information that you can use for debugging your hook code or external application.
session.GetEntity $session->GetEntity
Retrieves a record from the database.
session.EditEntity $session->EditEntity
Edits a record retrieved from the database.
[entity.]SetFieldValue $entity->SetFieldValue
Assigns a value to a field.
[entity.]Validate $entity->Validate
Ensures that the data in a record is acceptable before the record is saved to the database.
[entity.]Commit $entity->Commit
Commits the record, including any edits, to the database.
[entity.]Revert $entity->Revert
Cancels the changes. A good method to use if validation fails and the record is not committed.
[entity.]GetFieldValue $entity->GetFieldValue
Retrieves the field info object for the specified field.
FieldInfo.GetValue $FieldInfo->GetValue
Retrieves the values of a field.
session.BuildQuery $session->BuildQuery
Builds a query.
QueryDef.BuildField $QueryDef->BuildField
Includes a field in a query result set.
QueryDef.BuildFilterOperator QueryFilterNode.BuildFilterOperator $QueryDef->BuildFilterOperator $QueryFilterNode->BuildFilter Operator
Builds a filter operator for a query such as "equal to" or "greater than."
QueryFilterNode.BuildFilter $QueryFilterNode->BuildFilter
Creates support for a complex query.
session.BuildResultSet $session->BuildResultSet
Creates the ResultSet object necessary to run a query.
ResultSet.Execute $ResultSet->Execute
Runs the query with the current ResultSet object.
ResultSet.MoveNext $ResultSet->MoveNext
Moves the cursor to the next record in the data set.
ResultSet.GetColumnValue $ResultSet->GetColumnValue
Retrieves the value in the column you specify of the current row.
session.GetUserLoginName $session->GetUserLoginName
Gets the user's login ID.
entity.Revert $entity->Revert
Discards any changes made to the Entity object. Do not use the Revert API to stop the current action from within a hook. This API is only for reverting an action that was explicitly started within a hook or script. If you must stop the current action, use the exception mechanisms of the scripting language to throw an exception or cause the action-validation hook to return "false."