Summary

The previous value attributes can be used to access the question value present at form load. Two such attributes exist to access both the previous display value and previous data value.


  • previousValue – returns the data value that the question had when the form was loaded
  • previousDisplayValue – returns the display value that the question had when the form was loaded

The previous value attributes can be used with the following path-related script commands:

To access the previous value, the script path attribute should be followed by a colon and the applicable previous value attribute. For example, <s:datePath path=”/screening/dm.dob_:previousValue”/> will return the data value that the date of birth question had when the form was loaded.

The expressions below returns true if the previousValue was not set and should be used always with stringPath without any regards to the data type of the question that is checked.

<s:lt>
    <s:length>
        <s:value>
            <s:stringPath path=".someQuestion:previousValue"/>
        </s:value>
    </s:length>
    <s:number value="1" />
</s:lt>

Example – Display difference between previous value and new value within an alert

In the following example, if the question’s value was saved as 145 and then the value is changed to 195, an alert shall fire with the text, “The previous height was 145. The current height is now 195, which equates to a difference of 50. Is this value accurate?”

<script scriptId='previousValueCalculation'>
<body>
 <s:alert>
            <s:expression>
                <s:not>
                    <s:isSet>
                        <s:question>
                            <s:question path="/screening/demog.hgt_cm "/>
                        </s:question>
                    </s:isSet>
                </s:not>
            </s:expression>
            <s:correction>
                <s:string value='optional' />
            </s:correction>
            <s:text>
                <s:concat>
                    <s:string value="The previous height was "/>
                    <s:toString>
                        <s:numberPath path="/screening/demog.hgt_cm:previousValue" />
                    </s:toString>
                    <s:string value=". The current height is now "/>
                    <s:toString>
                        <s:numberPath path="/screening/demog.hgt_cm:value" />
                    </s:toString>
                    <s:string value=", which equates to a difference of "/>
                    <s:toString>
                        <s:subtract>
                          <s:numberPath path="/screening/demog.hgt_cm:value" />
                          <s:numberPath path="/screening/demog.hgt_cm:previousValue" />
                        </s:subtract>
                    </s:toString>
                    <s:string value=". Is this value accurate?"/>
                </s:concat>
            </s:text>
        </s:alert>
     </body>
    <target action="update" shouldReconcile="false" typeId="hgt_cm" when="preprocess"/>
</script>

Example – Send email when SAE severity question changes

In the following example, when the value of the “Severity of AE” question changes, the system sends an email to designated recipients regarding the previous display value and current display value.

<script desc="" desc2="" scriptId="emailValuesForSAE">
  <body>
    <s:if>
      <s:isSet>
        <s:question>
          <s:question path=".aesev" type="question"/>
        </s:question>
      </s:isSet>
      <s:email>
        <s:to>
          <s:list>
            <s:string value="rachel.workman@datatrak.com"/>
            <s:string value="robyn.workman@datatrak.com"/>
          </s:list>
        </s:to>
        <s:from>
          <s:string value="no-reply@datatrak.com"/>
        </s:from>
        <s:subject>
          <s:string value="Adverse Event Form Updated"/>
        </s:subject>
        <s:body>
          <s:concat>
            <s:string value="The value of question Severity of AE was: "/>
            <s:stringPath path="/aesum/ae[n].aesev:previousDisplayValue"/>
            <s:string value=". The new value is: "/>
            <s:stringPath path="/aesum/ae[n].aesev:displayValue"/>
          </s:concat>
        </s:body>
      </s:email>
    </s:if>
  </body>
  <target action="update" shouldReconcile="true" typeId="aesev" when="after"/>
</script>

Note: The full path, /aesum/ae[n].aesev, can also be written as .aesev.



Need more help?

Please visit the Fountayn Contact Information page.