JavaScript Functions > Alphabetical Listing of Utility Functions (lr) > lr.setTransaction

lr.setTransaction

Creates a completed transaction.

Example Transaction Functions

Syntax

lr.setTransaction( name, duration, status );

Arguments

Argument Comments
name A name for the transaction.
duration Transaction duration in seconds.
status The transaction completion status. One of the Transaction Status constants for pass, fail, or stop. The auto status is not applicable.

The lr.setTransaction function creates a transaction, its duration, and status in a single call. Use it where the business process you want to capture in a transaction does not consist of sequential steps, or where you may or may not want to create a transaction, depending on conditions that are known only during the test.

To create a transaction for non-sequential steps, capture the duration of each series of steps that participate in the business process. Sum the durations and create the transaction with lr.setTransaction.

To capture durations in C language scripts, use lr.startTimer and lr.endTimer. For other languages, use the native language time functions.

lr.setTransaction can also be used to report the duration of a failed transaction by saving the duration before the transaction fails with lr.getTransactionDuration then using lr.setTransaction to create a new transaction for reporting that time.

lr.setTransaction creates and closes the transaction. Therefore, no functions that work only on open transactions are applicable.

See also Example: Transactions

Note: Do not use the period character (.) in a transaction name. The period character delimits transactions and sub-transactions. In analysis, a transaction name with a period will be interpreted as two transactions.

Return Values

Not applicable

Parameterization

All string arguments can be parameterized using standard parameterization.

Example

lr.setTransaction("Multiple_Orders", 45.3, lr.PASS);