getPrevRepeatValue()
Fetch a value from the previous non-deleted row within the same instance, where the question of interest is entered. This function is available for repeating forms and repeating sections of two-section forms.
Tip:
You can use this function to get the value form a previous row for either the same or a different question.Syntax
getPrevRepeatValue('ruleVariable', [isNullConsidered])
Parameters
Note:
It is allowed to reuse variables passed into this function elsewhere in the rule expression, however you must add the variable as a parameter using single quotes.Parameter | Required/Optional | Description |
---|---|---|
ruleVariable |
Required | Name of the rule variable to get its value, passed in using single quotes. The rule variable is defined for a specific visit, form and item. |
isNullConsidered |
Optional | Boolean parameter to indicate if null values should
be included in the search.
|
Return value
Returns the value for the specified item in the immediate previous row. Depending on the optional parameter configuration, whether null is considered or not, can return any value (including null) from the immediate previous row, or the closest previous not null value, if the immediate previous row is null for the given item.
("[{\"value\":\"3\",\"label\":\"TestLabel\"}]")
Tip:
This can be parsed usingJSON.parse(result)
or the helper function
parseChoice(result)
.
Examples
Example 3-60 Get value of a given variable in the previous row
var prevValue= getPrevRepeatValue('vValue', false); //returns the first previous not null value
var prevValue= getPrevRepeatValue('vValue'); //returns the first previous value
Parent topic: Repeating form functions