Summary

This script runs when the subject id question of a study is saved on any form. In this case, the script is expecting a format of 4 consecutive integers. If that format is not found, it fires an alert to the user to indicate that the response should be modified. This alert is optional so the user can proceed without making the correction. If this is a required format (primary or secondary identifier of the application), the correction should be set to “required”. 


Script

<script scriptId="validateSubjectId">
    <body>
        <s:alert>
            <s:expression>
                <s:regex pattern="[0-9][0-9][0-9][0-9]">
                    <s:stringPath path=":value"/>
                </s:regex>
            </s:expression>
            <s:correction>
                <s:string value="optional"/>
            </s:correction>
            <s:text>
                <s:string value="Subject ID must be in the format of 4 valid integers. 
                Please correct."/>
            </s:text>
        </s:alert>
    </body>
    <target typeId="subjId" action="update" when="preprocess" shouldReconcile='true'/>
</script>



Need more help?

Please visit the Fountayn Contact Information page.