Sscalculation
Revision as of 13:32, 21 November 2011 by Arthur Lathrop (talk | contribs) (→Using sscalculation to Change Date Formats of Data in Custom Fields)
Revision as of 13:32, 21 November 2011 by Arthur Lathrop (talk | contribs) (→Using sscalculation to Change Date Formats of Data in Custom Fields)
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).
- If you need to pull information from the level 1 when you are at level 2 within the sscalculation tag, you can use the parent keyword
<!--@sscalculation(@year(parent.fullstartdate)@)-->
- To sum a value on a UTA Company field (Custom Field ID 123456) for all companies with role Funding Agency AND a value stored on the level 1 (Custom Field ID 545454) and format it with no decimal places:
<!--@sscalculation(format(( [#(?object=company;criteria=rolename='Funding Agency') $?opc_123456.value$ + #] @#545454.value#@),0))-->
- To find the average of all values (Custom Field ID 1755555) on a particular Level 2 Type (typeid=54321), excluding a particular status (statusid is not 10001), rounded to the nearest whole number:
<!--@sscalculation(format( ( [#(?object=activity;criteria=typeid='54321' and status.statusid not in ('10001')) $1755555$ + #] 0 )/@level2.count(*):typeid='54321' and status.statusid not in ('10001')@,0))-->
Using sscalculation to Change Date Formats of Data in Custom Fields
- To parse out date/time information from a custom field and display it in a different format, you can use the following syntax on level 2, referencing the field fieldname on level 1:
<!--@sscalculation(date_format("@parent.fieldname@","%M %d, %Y"))-->
- This is not necessary if the custom field being referenced is on the same level as the field referencing it. For example, if you are referencing a level 2 custom field in a web page view field on level 2. In this case, you can use the syntax outlined on the Web Page View Field Variables page.