Hook Function
Learn about Hook Function attribute.
Use the Hook Function
field attribute to define "field hooks" that perform calculations based on one or more field values.
Field hooks are small JavaScript functions that are executed whenever values of fields change. Field hooks are executed after the value entered by the user is written to the model (i.e. after validation and conversion).
Syntax
For information on the syntax, on handling different field types, on implementing asynchronous Hook Functions
etc, see the article “How to Define Field Hooks” at https://support.aurea.com.
Examples
Aurea CRM.Web contains an out-of-the-box function calculating the correct duration and unit depending on start date/time and end date/time. (You can use this function for any info area containing the respective fields). The following field hook is configured for the MA
Details control in UPDATE_DEFAULT as an example:
var fieldNames = {
startDate: "Date",
startTime: "Time",
endDate: "EndDate",
endTime: "EndTime",
duration: "Duration",
unit: "Unit"
};
u8.services.collaboration.updateDurationUnit($, fieldNames);
In the Property info area (OJ), you can define field hooks to set the ABC field to "A" whenever the Reference field is checked and to uncheck Reference if the Project Status field is set to "Lost".
To implement this you need to define two field hooks (in the OJ Details control):
Reference field:
var valuesAsBoolean = $.getNativeValue("Reference"); // true or false
if (valuesAsBoolean === true)
$.setValue("ABC","A");
Project Status field:
var catCode = $.getValue("ProjectStatus");
if (catCode == 2) // lost
$.setValue("Reference",false);