Upcoming: Calculated fields on client side

Calculation function for identifier field

In the videos above you may have noticed the automatic calculation of identifier field:

I concatenated Last Name, First Name, Middle Names (if exist) and Date of Birth (if exists), formatted as YYYY-MM-DD.

This is the code behind. I have added comments for better understanding.

// file: hooks/contacts-dv.js
// get a handle to detail view
var dv = AppGiniHelper.dv;

dv.getField("identifier").setFunction(function (data) {

    // if day_of_birth is defined
    //      then use moment.js library for formatting date into YYYY-MM-DD
    let date_string = data.day_of_birth ? new moment(data.day_of_birth).format("YYYY-MM-DD") : null;

    // get values of last_name, first_name, middle_names and date_strint into an array
    var parts = [data.last_name, data.first_name, data.middle_names, date_string]
        .filter(x => x) /* filter out empty values */
        .map(function (part) { /* convert values to uppercase */
            return part.toUpperCase();
        });

    let result = parts.join("-"); /* glue parts together using "-" character */
    return result; /* return the new string */
});

Summary

This is just the beginning. I have implemented setFunction() method now for my own beta testing. I'm pretty sure there will be more ideas while using it in custom projects. So, there may be changes in the future and perhaps small differences between the sample-code shown here today and the final code in next version of AppGini Helper Javascript Library.

I really hope you like it!

Stay safe, AppGineer's out there!

Kind regards,
Jan

Do you like it?