Difference between revisions of "Sscalculation"

From SmartWiki
Jump to: navigation, search
(Using sscalculation in a list)
(Using sscalculation in a List)
Line 28: Line 28:
  
 
* '''Important:''' There <u>must</u> be a space prior to the opening square bracket.
 
* '''Important:''' There <u>must</u> be a space prior to the opening square bracket.
* Also: don't forget the zero at the end of the statement. For example, if there are transactions with values of 10, 15 and 20 the statement between the square brackets would be translated as follows:
+
* Also: if you are finding the sum don't forget the zero at the end of the statement. For example, if there are transactions with values of 10, 15 and 20 the statement between the square brackets would be translated as follows:
 
::''[#(?object=transaction;)$add this$+#]'' &nbsp;&nbsp;&nbsp; becomes    &nbsp;&nbsp;&nbsp;  ''10+15+20+''
 
::''[#(?object=transaction;)$add this$+#]'' &nbsp;&nbsp;&nbsp; becomes    &nbsp;&nbsp;&nbsp;  ''10+15+20+''
 
so the 0 at the end ensures that the statement evaluated doesn't end with a plus sign (which will fail).
 
so the 0 at the end ensures that the statement evaluated doesn't end with a plus sign (which will fail).

Revision as of 17:54, 20 August 2009

Sscalculation is a variable syntax for:


This works similar to sslogic but will do calculations based on the formula you provide. It works as follows:


<!--@sscalculation(@field@*0.05)-->

This will return the computed value of @field@*0.05 and replaces the sscalculation tag.

This way you can do calculations right on the web page views without having to use javascript which solves the problem on PDF and javascript.

This method uses MySQL syntax, so you can do any MySQL functions like concat(...), format(...), round(...), etc.

Using sscalculation in a List

To obtain a Sum (for example) of the values in a Custom Field for all transactions associated with a Company/Contact using sscalculation:

<!--@sscalculation( [#(?object=transaction;)$add this$+#]0)-->


  • Important: There must be a space prior to the opening square bracket.
  • Also: if you are finding the sum don't forget the zero at the end of the statement. For example, if there are transactions with values of 10, 15 and 20 the statement between the square brackets would be translated as follows:
[#(?object=transaction;)$add this$+#]     becomes     10+15+20+

so the 0 at the end ensures that the statement evaluated doesn't end with a plus sign (which will fail).