Share this page

# lr.end_transaction

Marks the end of a transaction.

## JavaScript

    function lr.end_transaction(  transaction_name, status  )

## VBScript

    Function lr.end_transaction(  transaction_name, status  )

Transaction Functions

## Arguments

Name | Comments
--- | ---
transaction_name | A string indicating the name of an existing transaction.
status | The Transaction Status

The lr.end_transaction function marks the end of a transaction and records the amount of time it took to perform the transaction. To indicate a transaction to be analyzed, place the lr.start_transaction function before the transaction, and the lr.end_transaction function after the transaction.

You can manually set the status of the transaction or you can allow the script to detect it automatically. To manually set the status, you perform a manual check within the code of your script (see example) evaluating the return code of a function. For the "succeed" return code, set the status to LR_PASS. For a "fail" return code, set the status to LR_FAIL. For an "aborted" return code, set the status to LR_STOP.

If status is LR_AUTO, then the value of status is automatically assigned. By default, this value is LR_PASS signifying a successful transaction.

If you make a series of calls to functions that modify the LR_AUTO status, then it is the last call before lr.end_transaction which effectively changes the status.

## Return Values

On success, returns 0. Returns -1 if the transaction name is illegal or if there is no prior call to lr.start_transaction with a transaction of the same name.

## Parameterization

Standard parameterization is not available for this function.

## VBScript Examples

### Example 1 - Simple Transaction

The sample below illustrates timing the duration of a method call getStockList. The sample code does not check for exceptions.

Copy code

    lr.start_transaction("GetStocks");
    orStockServer1.getStockList();lr.end_transaction ("GetStocks", lr.PASS);

### Example 2 - Conditional transaction sample

The sample below illustrates timing the duration of the same sample code, however it adds checks for exceptions and ensures that the getStockList() method returns an non-zero length array.

Copy code

    Dim Stocks as String
    lr.start_transaction"GetStocks"
    On Error GoTo ErrorHandler
    Stocks = getStockList()
    if len(Stocks)= 0 then
        lr.end_transaction "GetStocks", lr.FAIL
        lr.message "No stocks returned"
    else
        lr.end_transaction "GetStocks", lr.PASS
    end if
    lr.message "Pass"
    Action = lr.PASS
    Exit Function

    ErrorHandler:
        Action = lr.FAIL
        lr.message "Fail"

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: