Changes

Jump to: navigation, search

SSlogic

4,095 bytes added, 15:16, 20 August 2020
no edit summary
[[Web Page View Field|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 uses the following syntax:
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:<brpre>&lt;<!--@sslogic(CONDITION)--><br> The content to be displayed when condition is true. This can be more than one line.<br>&lt;!--@end--><br/pre>
'''Condition''' is replaced with * The content to be displayed (the logical condition that your case calls formiddle line) can either be in plaintext or in HTML. The following code sample will display a Christmas tree image if * Be sure there are quotes (single or double) around the variable and only if it is currently Decembervalue. Note:<br>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.&lt;!--@* SSlogic does not support nested logic statements. In other words, you cannot put an sslogic statement within another sslogic(month(now())=12)--><br>statement.&lt;img src='images/xmasstree* NOTE: You cannot use sscalculation syntax within an sslogic statement. The sslogic syntax will manage the calculating. It does not require additional syntax prompts.jpg'><br>&lt;!--@end--><br>
Note that the content to be displayed (the middle line) can either be in plaintext or in HTML.
'''Example:''' * The following will display a Christmas tree image if the month is December: <pre><!--@sslogic(month(now())=12)--> <img src="images/xmasstree.jpg" alt="" /><!--@end--></pre> * Precede the equal sign with an exclamation point to test for '''Not Equal'''* The following will display a message for all provinces except Ontario: <pre><!--@sslogic("@province@"!="Ontario")--> You are outside of Ontario<!--@end--></pre> ==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: <pre><!--@sslogic("@sex@"="M")--> You are a guy.<br!--@else-->&lt; You are a girl.<!--@end--></pre> * 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: <pre><!--@sslogic('@sexparent.owner.clientgender@'='MMale')--> <brinput checked="checked" type="checkbox" /> Male <input type="checkbox" /> Female<!--@else--> <input type="checkbox" /> Male <input checked="checked" type="checkbox" /> Female<!--@end--></pre==Multiple Options ("else if" syntax):==You can use multiple "else if" operators if there are a guymore than just 2 options:  <nowiki><!--@sslogic(</nowiki>''condition 1'')-->aaa <nowiki><!--@else if(</nowiki>''condition 2'')-->bbb <nowiki><!--@else if(</nowiki>''condition 3'')-->ccc <nowiki><!--@else-->ddd </nowiki> <nowiki><!--@end--></nowiki></nowiki></nowiki></nowiki> '''Example:''' <pre><!--@sslogic("@possibility@"="Yes")--> This will happen for certain.<!--@else if("@possibility@"="No")--> This is not happening.<br!--@else if("@possibility@"="Maybe")-->&lt; This may or may not happen.<!--@else--> No-one knows what will happen.<!--@end--></pre> <!--per support ticket 17150 - Else if for sslogic -->==Multiple Conditions==* You can include more than one condition: <pre><!--@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--><br/pre==Fields Storing Single Quotes or Double Quotes==* SSlogic can be used to display fields that may have single quotes or double quotes stored within them.* The escape[] function is used to achieve this: <pre><nowiki><!--@sslogic('escape[$123456$]'!='')--></nowiki></pre><pre><nowiki><!--@sslogic('escape[@Field Name@]'!='')--></nowiki></pre>* NOTE: You must wrap the function using single quotes ==Using Object Lists==* Object [[Web_Page_View_Field_Variables#List|Lists]] can also be used in SSlogic. <pre><!--@sslogic("[#(?object=contact::criteria=rolename='Supervisor'::groupfunction=count)~userid~#]">0)--> There is at least one Supervisor<!--@else--> There are a girlno Supervisors<!--@end--></pre> ==Using With SSattach==* 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: <pre><!--@sslogic("@type@"="Contract")--> <!--@ssattach(after;/files/1234/123/myfilefooter.pdf)--><br!--@else-->&lt <!--@ssattach(after;/files/1234/123/myotherfilefooter.pdf )--><!--@end--><br/pre>:: '''''Note:''' [[ssattach]] can be used without sslogic if you want the same pdf file attached to the Web Page View in all cases.''==Notes==* 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==* [[Web Page View Field]]* [[Web Page View Field Variables]]* [[sscalculation]]  [[Category:Custom Fields]][[Category:Variables]]
Smartstaff
5
edits

Navigation menu