Store Value Across Sessions

Rapise includes API simplifying reading and storing of values between sessions:

  • Global.GetProperty('Propname', defValue) -- Read property value from %WORKDIR%\Config.json. See online help.

  • Global.SetProperty('PropName', value)-- Set property value to %WORKDIR%\Config.json. If the file does not exist it will be created. See online help.

Incrementing

Here is a sample function. Every time it is called the value is incremented by 1 and new value is returned as a string INV-nnn, where nnn is a new number.

function GlobalIncrementInvoiceNo()
{
    // Read invoice number (or 100 if no previous number set yet)
    var invoiceNo = Global.GetProperty('InvoiceNo', 100)
    // Increment value by 1
    invoiceNo++;
    // Store it for next use
    Global.SetProperty('InvoiceNo', invoiceNo)
    // Make final string like 'INV-123'
    return 'INV-'+invoiceNo;
}

You may put this function into Functions (<testname>.user.js) file.

Calling from RVL

Once function is defined in the .user.js it may be called from RVL using the Functions object (all global functions are shown as methods for this object).

Working Example

You may download and this sample test.