Calculated Properties

Properties within Entities can also be set to be "Calculated" within the App and when this checkbox is checked you are given the option of defining the calculation for the property. A very common use for this would be a database that has a first name field and a surname field, these would be properties in Evoke (linked to the database fields in data mappings) and then a further "User Interface Only" Property would be defined that is "calculated" as Firstname + Space + Surname. Examples are shown in the images on the right.
However, there are many other uses for Calculated Properties and Properties can can be calculated using one or more of the following types:
  • Arithmetic Expression - calculates a numeric value based on 2 or more Properties using "sum", "divide", "multiply" or calculate the "difference" of all the values in the Properties provided. Evoke will offer all the possible numeric Properties available e.g. Currency, Integer, Decimal, etc. You can select two values for the divide option; as many of the values as required for the sum or multiplication options; and add a sequence for the "difference" option by either selecting the options in a certain order or changing the sequence number.

  • Casing Conversion - this alters the case of a specified Alpha property value e.g. a name could be set to a) all lower case, b) First Letter Of All Words Is Uppercased or c) All Upper Case.

  • Collection Expression - this allows for a collection (multiple) properties to be a) averaged b) concatinated c) counted to return the number of values d) return the Highest of all the values e) return the lowest of all the values or f) summed. Evoke will ask you to select a source property , this will be a list of Entities (e.g. sales), then you select the related property, for example the sales price, which can be any property designated as a Currency, Integer, Decimal, etc numeric property.

  • Concatinate Properties - this allows mutiple values to be concatinated (joined), in any order you specifiy, with or without a) separators (as for the Full Name givin in the example above) b) changing the the case (as above) and c) being trimmed (removing initial, trailing or intermediate spaces).

  • Custom Code - this will add software "hooks" to allow you to simply and easily add some specific custom code into your Visual Studio project to calculate the value of the Property

  • Javascript - this allows a Javascript expression to be entered into Evoke that calculates the value of the Property

  • String Expression - formats the string based on the expression specified. Allows you to join together several property values. The "Add to String expression" adds the selected property to the string expression being built e.g. {propertyname1}*in*({propertyCountry1}) could result in Paul*in*(USA).

  • Value Conversion

    This will convert a value. The conversion options are based on the property type e.g a date can be converted to a) the day of the specified date b) the day of the week c) the full date d) the full year e) the ISO date f) the long date g) the month h) the month name i) a short date or j) just the year. Time can similarly be converted to various time formats.
    An Alphanumeric property can be converted with "field extract" - this allows you to extract the first part of a property, up to a field separator, into one property and the second part of a field into another (the field index is 0 for the first part and 1 for the second, etc). There is an example of this in the image on the right.
    Numeric - this allows zeros to be converted to blanks and blanks to be converted to zeros.

When you have completed your selection for the calculated property then use the accept or reject buttons to commit the calculation or cancel it.


Calculated Entity Property
An entity property that is flagged as being calculated has its own dedicated builder page. This allows the you to identify which property values are required to identify the related entity instance(s). If only one property is included in the "to be used" list and the entity property is not a list then a checkbox at the foot of the list allows you to specify if the specified property supplies the complete primary key/item ID of the related data item. The key feature of a calculated entity property is that if any of its dependency property values change, the appropriate data retrieval action will be triggered automatically.

MultiValue Custom Entity key storage
In the Data Mappings area, for a MultiValue repository, the "Custom" Entity key storage option allows you to indicate that some custom DataBASIC code will handle the reading of data for this entity relationship. If this option is chosen, you are able to enter a comma separated list of attribute numbers indicating which fields of data from the parent item are to be supplied to the custom code in order for the correct entity instance(s) to be retrieved. Within the .CUSTOM CRUD routine, if the routine has been called as part of a related data retrieval attribute #4 of the ControlIn argument will be set the "Custom" and the DataIn argument will be set to a value mark separated list of values corresponding to the list of attribute numbers defined within the data mappings page. If the entity property is a single value, the "Read" CRUD action will be called to retrieve the related data. Alternatively, if it is a list property the "ReadMultiple" CRUD action will be called.

Calculated entity property and Custom Entity key storage
There is a loose relationship between the 2 above features in that if an entity property does not have the complete item ID of the related data supplied by a property value, then it is implied that some custom CRUD must be used to retrieve the related data.