Changes

Jump to navigation Jump to search
no edit summary
Line 31: Line 31:     
=== Access to attributes in a Calculation field ===
 
=== Access to attributes in a Calculation field ===
Access to the value of an attribute in a Calculation field is performed using the symbol ? (question mark):
+
Access to the value of an attribute in a Calculation field is performed using the colon (:):
* #{link field name?attribute name}
+
* #{link field name:attribute name}
    
==== For example, to access the Count attribute, use the following syntax ====
 
==== For example, to access the Count attribute, use the following syntax ====
 
* #{items?count}
 
* #{items?count}
 
If the field contains several links to entries, then you can use the index to access the attribute:
 
If the field contains several links to entries, then you can use the index to access the attribute:
* #{items@0?count}, #{items@1?count}
+
* #{items@0:count}, #{items@1:count}
    
=== Aggregation of attributes in a Calculation field ===
 
=== Aggregation of attributes in a Calculation field ===
 
If the Link to Entry field contains several linked entries and each of them has its own attribute value, then one of the aggregation functions can be applied to these attributes. For example, to calculate the sum of all the attributes:
 
If the Link to Entry field contains several linked entries and each of them has its own attribute value, then one of the aggregation functions can be applied to these attributes. For example, to calculate the sum of all the attributes:
* $sum('link field name?attribute name')
+
* $sum('link field name:attribute name')
    
Aggregation functions support pairwise operations between different fields of linked entries and attributes:
 
Aggregation functions support pairwise operations between different fields of linked entries and attributes:
 
// This function multiplies the linked_field_name field of each associated entry by the corresponding attribute_name attribute.  
 
// This function multiplies the linked_field_name field of each associated entry by the corresponding attribute_name attribute.  
 
// The set of numbers obtained after multiplication is summed.  
 
// The set of numbers obtained after multiplication is summed.  
* $sum('link_field_name.linked_field_name', 'link_field_name?attribute_name', ' @ mul')
+
* $sum('link_field_name.linked_field_name', 'link_field_name:attribute_name', ' @ mul')
    
For example, to calculate the total amount of an order, you can use the formula:
 
For example, to calculate the total amount of an order, you can use the formula:
 
// This formula multiplies the value of the price field of the linked entry in pairs by the value of the attribute count of the linked entry.
 
// This formula multiplies the value of the price field of the linked entry in pairs by the value of the attribute count of the linked entry.
 
// The set of numbers obtained after multiplication is summed.  
 
// The set of numbers obtained after multiplication is summed.  
$sum('items.price', 'items?count', '@mul');
+
$sum('items.price', 'items:count', '@mul');

Navigation menu