Difference between revisions of "SmartCheck Validation"
Line 70: | Line 70: | ||
=Examples= | =Examples= | ||
− | ====Application Name field black | + | ====Application Name field black==== |
<pre>if(form.getStr("sf_Application Name") == "") | <pre>if(form.getStr("sf_Application Name") == "") | ||
{result.isPassed=false; | {result.isPassed=false; | ||
Line 76: | Line 76: | ||
}</pre> | }</pre> | ||
− | ====Requested Amount less than X | + | ====Requested Amount less than X==== |
<pre>if(ssParseNum(form.getStr("cf_Requested Amount")) < "5000") | <pre>if(ssParseNum(form.getStr("cf_Requested Amount")) < "5000") | ||
{result.isPassed=false; | {result.isPassed=false; | ||
Line 82: | Line 82: | ||
}</pre> | }</pre> | ||
− | ====Number value greater than 5 | + | ====Number value greater than 5==== |
<pre>if(ssParseNum(form.getStr("cf_Store Value")) > 5) | <pre>if(ssParseNum(form.getStr("cf_Store Value")) > 5) | ||
{result.isPassed=false; | {result.isPassed=false; | ||
Line 89: | Line 89: | ||
</pre> | </pre> | ||
− | ====Single field upload field has no file | + | ====Single field upload field has no file==== |
<pre>if("@Single File Field.filename@" == "") | <pre>if("@Single File Field.filename@" == "") | ||
{result.isPassed=false; | {result.isPassed=false; | ||
Line 96: | Line 96: | ||
</pre> | </pre> | ||
− | ====Multi file upload field has no files | + | ====Multi file upload field has no files==== |
<pre>if(ssParseNum("@level1.MUlti upload.numoffiles@") < 1) | <pre>if(ssParseNum("@level1.MUlti upload.numoffiles@") < 1) | ||
{result.isPassed=false; | {result.isPassed=false; | ||
result.addMsg('Please upload at least one file'); } | result.addMsg('Please upload at least one file'); } | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | ===Comparing two custom date fields with separate custom time fields storing 24 hour time=== | ||
+ | <pre>if(form.getStr("cf_Event Start Date")+' '+form.getStr("cf_Event Start Time") >= form.getStr("cf_Event End Date")+' '+form.getStr("cf_Event End Time")) | ||
+ | {result.isPassed=false; | ||
+ | result.addMsg('cf_@Event End Time.id@','End Time must take place after the Start Time'); } | ||
+ | </pre> | ||
+ | |||
====To include other scripts from SmartCheck script:==== | ====To include other scripts from SmartCheck script:==== |
Revision as of 09:55, 7 December 2015
Contents
- 1 Overview
- 2 SmartCheck Validation Structure
- 3 Enabling SmartCheck Validation
- 4 Examples
Overview
SmartCheck Validation enables your SmartSimple system to perform server-side field validations ensuring that applications and form inputs meets your requirements.
These validations are performed on “submit” actions and returns failed field entries with your specified error messages. These messages are displayed at the top of the form and on-click will take the user to referenced field.
SmartCheck Validation Structure
Each SmartCheck Validation statement shares the following structure:
- If Statement (thing to be compared)
- Result (true or false result)
- Message (to be displayed on failed result)
In the example below:
if(ssParseNum(form.getStr("cf_Store Value")) > 5) {result.isPassed=false; result.addMsg('Some message here'); }
Recognize the If, Result, Message structure:
if(ssParseNum(form.getStr("cf_Store Value")) > 5)
Check If the contents the of the form value (stored in the custom field named cf_Store_Value) is greater than 5,
{result.isPassed=false;
If the statement is false, set the value of the Result to "false" and print the custom message below.
result.addMsg('Some message here'); }
Enabling SmartCheck Validation
SmartCheck Validation can be enabled system-wide, for Users and Companies, or on a UTA-by-UTA basis.
Before you can enable SmartCheck Validation on your system you’ll need Global Administrator privileges.
To enable the feature system-wide:
- Under the Configuration menu click on Global Settings.
- Add a check mark to the Activate SmartCheck Validation box under System Configuration.
To enable the feature for Users and Companies:
- Under the Configuration menu click on Global Settings.
- Click on the Organizations and Users tab
- Add a check mark to the SmartCheck Validation box under System Configuration.
- Click on New Validation
- Using the Code Builder or Source tabs, enter your validation details.
- Click Save when done
To enable the feature on a specific UTA:
- Navigate to the desired UTA-by-UTA
- Click on Settings
- Under the L1, L2, or L3 click on the SmartCheck Validation link under the Properties menu.
- Click on New Validation
- Using the Code Builder or Source tabs, enter your validation details.
- Click Save when done
Examples
Application Name field black
if(form.getStr("sf_Application Name") == "") {result.isPassed=false; result.addMsg('Application name cannot be blank'); }
Requested Amount less than X
if(ssParseNum(form.getStr("cf_Requested Amount")) < "5000") {result.isPassed=false; result.addMsg('cf_@Requested Amount.id@','Field test message'); }
Number value greater than 5
if(ssParseNum(form.getStr("cf_Store Value")) > 5) {result.isPassed=false; result.addMsg('Some message here'); }
Single field upload field has no file
if("@Single File Field.filename@" == "") {result.isPassed=false; result.addMsg('Please upload a file here'); }
Multi file upload field has no files
if(ssParseNum("@level1.MUlti upload.numoffiles@") < 1) {result.isPassed=false; result.addMsg('Please upload at least one file'); }
Comparing two custom date fields with separate custom time fields storing 24 hour time
if(form.getStr("cf_Event Start Date")+' '+form.getStr("cf_Event Start Time") >= form.getStr("cf_Event End Date")+' '+form.getStr("cf_Event End Time")) {result.isPassed=false; result.addMsg('cf_@Event End Time.id@','End Time must take place after the Start Time'); }
To include other scripts from SmartCheck script:
//@include(AnotherSmartCheckScriptName)