Table of Contents
Using custom function for full_name field
Instead of passing an array of strings, representing the fieldnames, we can pass a custom function to the field.setFunction()-method:
// file: hooks/contacts-dv.js
var dv = AppGiniHelper.dv;
// calculate field "full_name"
// concat values of last_name, first_name, middle_names
// readable version for beginners
dv.getField("full_name").setFunction(function (data) {
var result = data.last_name;
if (result && data.first_name) result += ", " + data.first_name;
if (result && data.middle_names) result += ", " + data.middle_names;
return result;
});
We can return a string containg the new value for the full_name-field.
Tipp: console.log(data);
Please note the data parameter. You can check the values by printing out that variable:
dv.getField("full_name").setFunction(function (data) {
console.log(data);
// ...
});
This is the console-output:

Pro-Tipp
Here is a different code returning similar results for more advanced Javascript users:
// using array, filter and join
dv.getField("full_name").setFunction(function (data) {
var parts = [data.last_name, data.first_name, data.middle_names].filter(x => x);
return parts.join(", ").trim();
});
Next: More complex calculation for identifier field
See page 3 for more functionality.
