Difference between revisions of "SSlogic"
From SmartWiki
Line 24: | Line 24: | ||
* The following will display a message for all provinces except Ontario: | * The following will display a message for all provinces except Ontario: | ||
<pre> | <pre> | ||
− | <!--@sslogic( | + | <!--@sslogic("@province@"!="Ontario")--> |
You are outside of Ontario | You are outside of Ontario | ||
<!--@end--> | <!--@end--> | ||
Line 33: | Line 33: | ||
* The following sample code will display one message if a user is male and another if the user is female: | * The following sample code will display one message if a user is male and another if the user is female: | ||
<pre> | <pre> | ||
− | <!--@sslogic( | + | <!--@sslogic("@sex@"="M")--> |
You are a guy. | You are a guy. | ||
<!--@else--> | <!--@else--> | ||
Line 54: | Line 54: | ||
You can use multiple sslogic statements if there are more than just 2 options: | You can use multiple sslogic statements if there are more than just 2 options: | ||
<pre> | <pre> | ||
− | <!--@sslogic( | + | <!--@sslogic("@possibility@"="Yes")--> |
This will happen for certain. | This will happen for certain. | ||
<!--@end--> | <!--@end--> | ||
− | <!--@sslogic( | + | <!--@sslogic("@possibility@"="No")--> |
This is not happening. | This is not happening. | ||
<!--@end--> | <!--@end--> | ||
Line 97: | Line 97: | ||
==Note== | ==Note== | ||
* sslogic can be used in workflow e-mails at Level 1 only. | * sslogic can be used in workflow e-mails at Level 1 only. | ||
+ | * In general double quotes (") should be used to enclose variables rather than single quotes ('). If the content includes an apostrophe (equivalent to a single quote) it will disrupt the processing. Double quotes are less common as content. You may want to add an [[Removing Special Characters|onchange]] to the source field to prevent entry of double quotes. | ||
==See Also== | ==See Also== |
Revision as of 10:01, 21 March 2012
Web Page View fields can use a unique SmartSimple logic interpreter. Web page logic gives you the ability to display certain content or perform certain actions only when specified conditions are met. SmartSimple logic follows the following template:
<!--@sslogic(CONDITION)--> The content to be displayed when condition is true. This can be more than one line. <!--@end-->
- The content to be displayed (the middle line) can either be in plaintext or in HTML.
- Be sure there are quotes (single or double) around the variable and value. Note: Your choice in the use of quotes depends on the variable's contents. E.g. names containing apostrophes should use double quotes when referencing that variable.
- SSlogic does not support nested logic statements.
Example:
- The following will display a Christmas tree image if the month is December:
<!--@sslogic(month(now())=12)--> <img src='images/xmasstree.jpg'> <!--@end-->
- Precede the equal sign with an exclamation point to test for Not Equal
- The following will display a message for all provinces except Ontario:
<!--@sslogic("@province@"!="Ontario")--> You are outside of Ontario <!--@end-->
Else Logic:
- Often, you will want to display one of two texts--one text in the case that a condition is met and another in the case that the condition is not met. This is achieved through the use of an "else" operator.
- The following sample code will display one message if a user is male and another if the user is female:
<!--@sslogic("@sex@"="M")--> You are a guy. <!--@else--> You are a girl. <!--@end-->
- The following will display 2 check boxes. If the gender is male the first check box (Male) will be ticked. If the gender is female the second check box will be ticked:
<!--@sslogic('@parent.owner.clientgender@'='Male')--> <input type="checkbox" checked> Male <input type="checkbox"> Female <!--@else--> <input type="checkbox"> Male <input type="checkbox" checked> Female <!--@end-->
Multiple Options: You can use multiple sslogic statements if there are more than just 2 options:
<!--@sslogic("@possibility@"="Yes")--> This will happen for certain. <!--@end--> <!--@sslogic("@possibility@"="No")--> This is not happening. <!--@end--> <!--@sslogic('@possibility@'='Maybe')--> This may or may not happen. <!--@end-->
Multiple Conditions:
- You can include more than one condition:
<!--@sslogic('@year@'='2008' AND ('@month@'='1' OR '@month@'='2'))--> This is only displayed if the year is 2008 and the month is either Jan or Feb. <!--@end-->
Fields Storing Single Quotes:
- SSlogic can be used to display fields that may have a single quote stored within them.
- The escape[] function is used to achieve this:
<!--@sslogic('escape[$1137762$]'!='')-->
- SSlogic can be used to determine which pdf file is appended to the Web Page View using ssattach
- The following example will attach myfilefooter.pdf if the Type/Template is Contract, and myotherfilefooter.pdf if not:
<!--@sslogic('@type@'='Contract') --> <!--@ssattach(after;/files/1234/123/myfilefooter.pdf )--> <!--@else--> <!-- @ssattach(after;/files/1234/123/myotherfilefooter.pdf )--> <!--@end-->
- Note: ssattach can be used without sslogic if you want the same pdf file attached to the Web Page View in all cases.
Note
- sslogic can be used in workflow e-mails at Level 1 only.
- In general double quotes (") should be used to enclose variables rather than single quotes ('). If the content includes an apostrophe (equivalent to a single quote) it will disrupt the processing. Double quotes are less common as content. You may want to add an onchange to the source field to prevent entry of double quotes.