Calculation function for identifier
field
In the videos above you may have noticed the automatic calculation of identifier field:
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?
We can only get better if you give us constructive suggestions for improvement. Just voting "No" without giving reasons or suggestions is not helpful and cannot lead to changes.
If you have been searching for a completely different solution than the subject says, this article can not be and will not be helpful for you. In these cases you should consider not to vote.
This is website feedback, only. This voting is not a support form nor ticket system.