New to Tapforms and trying to add a field for the latest date. I have tried using Maximum on the date field, but the result is not what I expect. The calculation is automatically filling in “Count”. The fields are joined in the two forms. In the pdf attached, I have included the field setup, calculation and the results…it is showing the date of Dec 31 1969 instead of Sep 30, 2020.
I also tried to change “Count” to “Max”, but it will not let me.
Any suggestions are appreciated.
Attachments:
You must be
logged in to view attached files.
A script field would work.
var when_id = 'fld-a13ae3e64dd340138d08e719fe2a9aa9';
var childform_id = 'fld-8ead2e10d2634bd4925175d72f943857';
function Max() {
var arr = record.getFieldValue(childform_id);
arr.sort(compare);
return arr[0].getFieldValue(when_id);
}
function compare(a, b) {
if (a.getFieldValue(when_id) > b.getFieldValue(when_id)) {
return -1;
} else if (b.getFieldValue(when_id) > a.getFieldValue(when_id)) {
return 1;
}
return 0;
}
Max();
You will need to get your field ID’s.
Make sure you set the return results type to Date.
Thanks so much. I will give this a try.
I am so very excited! I could not get this to work at first due to my limited knowledge, but after watching a couple of Sam Moffitt’s YouTubes and retrying to make sure I was picking the right fields, I got it to work. Thanks so very much!!!!
That’s awesome! I’m so glad!
The scripting is powerful, but it also has a fairly steep learning curve. I have an intro to scripting here: http://cattail.nu/tap_forms/tap_forms_scripting_101/index.html
– T
Thanks for the link! I am definitely going to review it.