Changes

Jump to: navigation, search

Template / Type Formula

1,173 bytes removed, 16:51, 25 September 2013
no edit summary
Level One, Level Two and Level Three records can perform advanced calculations and logic within their Formula boxes.
 
 
 
==General Information==
{{l1}}Level One, {{l2}} Level Two and {{l3}} Level Three records can perform advanced calculations and logic within their Formula boxes. Formulas can be defined in 2 different locations for each of the Levels within the [[UTA]]* The formulas on the Application Configuration page apply to all records saved at the specified Level.* The formulas the Template page (Level 1) or Type page (Levels 2 and 3) apply to records on the given Template/Type only.  If you wish to perform calculations on fields associated with Level 3, but store the results in fields at the Level 2, you use the '''Level 2 Formula''' field. You can use any expression and also some built in functions.
You may also wish to use Template Formulas can be defined in two different locations for each instead of a Calculated field because the levels within calculations are done server side, rather than by the [[UTA]]browser.<br> * The formulas Thus if you are doing a calculation on the [[UTA Settings - Entity|UTA Settings Page]] apply a value that needs to all records saved at the specified Level.* The formulas be populated or calculated on the [[Level 1 Templates|Template]] page (Level 1) or [[same Level 2 Types|Type]] page (Levels 2 and 3) apply item, this will avoid you having to records on save twice in order to get the given Template/Type onlyfinal result.
If you wish to perform calculations on fields associated with Level 3, but store the results in fields at the Level 2, you use the '''Level 2 Formula''' field. You can use any expression and also some built-in functions.
You may also wish to use Template Formulas instead of a [[Custom Field Type: Special – Calculated Value|Calculated Value field]] because the calculations are done server-side, rather than by the browser.<br>
Thus, if you are doing a calculation on a value that needs to be populated or calculated on the same Level 3 item, this will avoid you having to save twice in order to get the final result.
===Execution Sequence===
* The Formulas are calculated when a record is saved.
* The ''General'' formula for the on the [[UTA Settings - Entity|UTA Settings Page]] Application Configuration page is executed first, followed by the [[Template]]/[[Type]] specific formula (if present).
* Saving a Level 2 or Level 3 record will also initiate the formulas on the parent level(s):
===Counting and Adding Business Days===
Aside from using [[Counting Business Days between Two Dates|Javascript]] to count business days, there are two 2 SmartSimple functions you can use within the {{l1}}L1, {{l2}}L2, and {{l3}} L3 template formula to count and add business days to any Date field.
'''To count the number of business days between two 2 date fields, use the following function:'''
'''SS_FUNC.countbusdays('Date1','Date2')'''
This example below calculates the number of business days between the Start Date and End Date.
'''@level1.DateDifference@=SS_FUNC.countbusdays('@level1.Startdate@','@level1.Enddate@')'''
 
 
'''To increment a date by a number of business days, use the following function:'''
'''@level1.DateDifference@=SS_FUNC.addbusdays('@level1.Startdate@',5)'''
Note in order to take into considering holidays into consideration, you will need to create a holiday [[Holiday Entering_a_New_Calendar_Event|Calendar]] and associate this calendar calender as the holiday calendar within [[Global Settings]].  
==Examples==
* To count the number of ''Companies'' of a certain type assigned to Level 1, use the following statement in the Level 1 template formula box:
@opportunity.#123456#@="@companies.count(*):rolename='EPS Partner'@";
 
* If you want to assign company of the Level 1 '''Owner''' to the Level 1 '''Customer''' field you would use the following:
@level1.companyid@=@level1.owner.companyid@;
:''Note: the '''Customer''' field can be be hidden, and will still populate. This is true for all Template/Type formulas.''
* To assign the owner of the company attached to the Level 1 item to the ''Person'' field use the following statement in the Level 1 template formula box:
@opportunity.peopleid@=@company.ownerid@
==Using a Level 2 Type Formula==
In order to use this technique in the current example, you will need to first enable the duration field in the Level 2 activity:.
1. Click '''Settings'''.
2. Click on the [[UTA Settings - Entity|Entity tab]]'''Application Configuration'''.
3. Click the '''Activity Settings''', '''Standard Fields''' link.
Go to level 2 template and use the following format @level2.#50235#@=@level3.sum(#50291#):eventtype=8866@
where 50235 is the custom field in which where you want the value to be storedstore in, 50291 is the custom field that you want to sum, and 8866 is the level 3 [[Determining the typeid|type ID]].,
Note: Currently the system doesn't support summing from level 3 to level 1 using a custom field id. The summing would only work with Amount and Duration field.
 
==Using a Level 3 Type Formula==
You can use the Level 3 Type Formula setting field on the Level 3 Type page in a similar manner as for Level 2.* The advantage of using a Level 3 Type Formula instead of a Calculated field is that the calculations are done server side, rather than by the browser.<br /> Thus if you are doing a calculation on a value that needs to be populated populate or calculated on the same Level 3 item, this will avoid you having to save twice in order to get the final result.
'''@level3.total@=@level3.rate@*@level3.quantity@'''
''or using the fieldids fieldid instead of the field namesfieldname''
'''@level3.#123100#@=@level3.#123098#@*@level3.#123099#@'''
THEN 'Thank for your submission' WHEN 'Status 3' THEN 'Congratulations' ELSE 'I have no comment' END;
 
==Using List Syntax ([#(?object=... #])==
The normal [#...#] syntax for listing multiple object such as listing all Level 2 objects attached to a Level 1 can be used.
* Because Template Formulas use semi-colons to delimit separate activities you must replace the semi-colon prior to the criteria and/or sort order with two colons:
* @level1.name@="@level1.[#(?object=activity::criteria=eventtype=1234) ~eventtype~ #]@"
==Additional Information==
* You cannot change the [[Status]] using a Template / Type Formula. '''Note''': Currently this works for level 2 only. You can use @level2.statusid@='12345'; to change the status of a level 2 using a template formula (Any workflows at that status are not triggered).
* You can trigger execution of the Template / Type formulas against a group of records without opening and saving them using the [[Batch Update]] feature.
* You can't have comments in formulas.
==See Also==
* [[The Musings of Chin - Template Formulas]]
* [[The Musings of Chin - SmartSimple's Order of Operations]]
* [[Role Formula]]
* [[Adding Business Days]]
* [[Counting Business Days between Two Dates]]
{{PrevNextStart}} [[Setting Standard Fields for Level 3]]{{PrevNextMid}} [[Enabling the Security MatrixCategory:Universal Tracking Application]] {{PrevNextEnd}} [[Category:Universal Tracking ApplicationDate Formats]]
8,849
edits

Navigation menu