Difference between revisions of "SmartCheck Validation"

From SmartWiki
Jump to: navigation, search
Line 7: Line 7:
 
     {result.isPassed=false;
 
     {result.isPassed=false;
 
     result.addMsg('Application name cannot be blank');
 
     result.addMsg('Application name cannot be blank');
     }</pre
+
     }</pre>
 +
 
 
====Number value greater than 5 -> Fail:====
 
====Number value greater than 5 -> Fail:====
 
<pre>if(ssParseNum(form.getStr("cf_Store Value")) > 5)
 
<pre>if(ssParseNum(form.getStr("cf_Store Value")) > 5)
Line 14: Line 15:
 
     }
 
     }
 
</pre>
 
</pre>
 +
 
====Single field upload field has no file -> Fail:====
 
====Single field upload field has no file -> Fail:====
 
<pre>if("@Single File Field.filename@" == "")
 
<pre>if("@Single File Field.filename@" == "")
Line 20: Line 22:
 
     }
 
     }
 
</pre>
 
</pre>
 +
 
====Multi file upload field has no files -> Fail:====
 
====Multi file upload field has no files -> Fail:====
 
<pre>if(ssParseNum("@level1.MUlti upload.numoffiles@") < 1)
 
<pre>if(ssParseNum("@level1.MUlti upload.numoffiles@") < 1)
Line 25: Line 28:
 
     result.addMsg('Please upload at least one file');    }
 
     result.addMsg('Please upload at least one file');    }
 
</pre>
 
</pre>
 +
 
====End date is before Start date -> Fail:====
 
====End date is before Start date -> Fail:====
 
<pre>if (datediff('@date(startdate)@','@date(enddate)@','d') < 0)
 
<pre>if (datediff('@date(startdate)@','@date(enddate)@','d') < 0)
 
     {result.addMsg('End date must be later than Start date'));
 
     {result.addMsg('End date must be later than Start date'));
 
     result.isPassed=false;
 
     result.isPassed=false;
     }</pre>
+
     }
 +
</pre>
 +
 
 
====To include other scripts from SmartCheck script:====
 
====To include other scripts from SmartCheck script:====
<pre>//@include(AnotherSmartCheckScriptName)</pre>
+
<pre>//@include(AnotherSmartCheckScriptName)
 +
</pre>

Revision as of 13:59, 4 December 2015

Template:UnderConstruction


Examples

Application Name field black -> Fail:

if(form.getStr("sf_Application Name") == "")
    {result.isPassed=false;
    result.addMsg('Application name cannot be blank');
    }

Number value greater than 5 -> Fail:

if(ssParseNum(form.getStr("cf_Store Value")) > 5)
    {result.isPassed=false;
    result.addMsg('Some message here');
    }

Single field upload field has no file -> Fail:

if("@Single File Field.filename@" == "")
    {result.isPassed=false;
    result.addMsg('Please upload a file here');
    }

Multi file upload field has no files -> Fail:

if(ssParseNum("@level1.MUlti upload.numoffiles@") < 1)
    {result.isPassed=false;
    result.addMsg('Please upload at least one file');    }

End date is before Start date -> Fail:

if (datediff('@date(startdate)@','@date(enddate)@','d') < 0)
    {result.addMsg('End date must be later than Start date'));
    result.isPassed=false;
    }

To include other scripts from SmartCheck script:

//@include(AnotherSmartCheckScriptName)