Summary

This article covers script examples for attributes used for question value paths. 

Table of Contents


Available Attributes

For the question value paths (datePath, numberPath, partialDatePath or stringPath) the following attributes can be used:

  • alias – returns the alias of the node
  • answer – returns the answer status of the node. Possible values are completed, blank, or inProgress.
  • createDate – returns the create date of the form. If the form is null, returns the create date of the record
  • dateFormat – returns the date format of the question. If the question is null it returns “dd-MM-yyyy”
  • displayValue – returns the display value for the node
  • id – returns the question or form id of the node
  • lock – returns the lock status of the node. Possible values are locked and open.
  • freeze – returns the freeze status of the node. Possible values are frozen or unfrozen.
  • name – returns the name of the node (form name for forms and the text of the question for questions)
  • previousValue – returns the previous value of the question
  • previousDisplayValue – returns the previous display value of the question
  • query – returns the query status of the node. Possible values are openQuery or clean.
  • sign – returns the signed status of the node. Possible values are yes or no.
  • type – returns the typeID of the node (formType for forms and questionType for questions)
  • validation – returns the validation status of the node. Possible values are yes or no.
  • value – returns the value entered by the client for the question
  • violation – returns the violation status for the node. Possible values are clean, alertClosedOverride, alertClosed, alertOpenOverride, and violation.


Examples

:alias

Sample Requirement: An alert should fire on testResult_1, 2,3,4 only (and not to fire on testResult5) if the question is answered and its value is more or less than +/-10% of the average calculated on the answered only questions 1,2,3,4,5.

 <script scriptId="alertTestResult_1">
        <body>
            <s:alert>
                <s:expression>
                    <s:or>
                        <s:not>
                            <s:isSet />
                        </s:not>
                        <s:eq>
                            <s:stringPath path=".:alias" />
                            <s:string value="testResult_5" />
                        </s:eq>
                        <s:and>
                            <s:lte>
                                <s:numberPath path=".:value" />
                                <s:multiply>
                                    <s:average>
                                        <s:numberPath path=".testResult_1:value" />
                                        <s:numberPath path=".testResult_2:value" />
                                        <s:numberPath path=".testResult_3:value" />
                                        <s:numberPath path=".testResult_4:value" />
                                        <s:numberPath path=".testResult_5:value" />
                                    </s:average>
                                    <s:number value="1.1" />
                                </s:multiply>
                            </s:lte>
                            <s:gte>
                                <s:numberPath path=".:value" />
                                <s:multiply>
                                    <s:average>
                                        <s:numberPath path=".testResult_1:value" />
                                        <s:numberPath path=".testResult_2:value" />
                                        <s:numberPath path=".testResult_3:value" />
                                        <s:numberPath path=".testResult_4:value" />
                                        <s:numberPath path=".testResult_5:value" />
                                    </s:average>
                                    <s:number value="0.9" />
                                </s:multiply>
                            </s:gte>
                        </s:and>
                    </s:or>
                </s:expression>
                <s:correction>
                    <s:string value="optional"/>
                </s:correction>
                <s:text>
                    <s:string value="Test Result greater or less than average +/- 10% of the available results.  Please verify."/>
                </s:text>
            </s:alert>
        </body>
        <target action="update" typeId="testResult" when="preprocess"/>
    </script>


:id

Sample Requirement: Visit 1 forms should generate when vsdat on formID sv_1v is set and if the id of the node equals the numberPath path to the target.
Note: Use of :id allows the ability to trigger scripts on specified visits even though multiple visits may have a vsdat question. This helps to prevent multiple scripts from triggering off of one vsdat being set. If the script goes to the question level use the numberPath path of the target. If the script goes to the form level use the numberPath path of the form.


<script scriptId="create_1v">
    <body>
        <s:if>
            <s:and>
                <s:isSet>
                    <s:question>
                        <s:question path="/visit_1v/sv_1v.vsdat"/>
                    </s:question>
                </s:isSet>
                <s:eq>
                     <s:numberPath path=":id"/>
                     <s:numberPath path="/visit_1v/sv_1v.vsdat:id" />
                </s:eq>
            </s:and>
            <s:list>
                <s:createForm>
                    <s:parent>
                        <s:form path="/visit_1v"/>
                    </s:parent>
                    <s:type>
                        <s:string value="vs"/>
                    </s:type>
                    <s:alias>
                        <s:string value="vs_1v"/>
                    </s:alias>
                </s:createForm>
    <s:createForm>
                    <s:parent>
                        <s:form path="/visit_1v"/>
                    </s:parent>
                    <s:type>
                        <s:string value="lbs"/>
                    </s:type>
                    <s:alias>
                        <s:string value="lbs_1v"/>
                    </s:alias>
                </s:createForm>
                <s:createForm>
                    <s:parent>
                        <s:record/>
                    </s:parent>
                    <s:type>
                        <s:string value="aes"/>
                    </s:type>
                    <s:alias>
                        <s:string value="aes"/>
                    </s:alias>
                </s:createForm>
            </s:list>
        </s:if>
    </body>
    <target action='update' shouldReconcile='true' typeId='vsdat' when='after' />
</script>



Need more help?

Please visit the Fountayn Contact Information page.