This is such a basic question, Im sure it’s been asked but I can not find the answer.
For Example Main Form is a Customer
Linke form is list of orders
I want to show the latest order date, from the order form , on the Parent Customer Form. So I can see it on the Record list for the Customers.
Oh, yes. I am using a JOIN relationship which is working perfectly.
I can not find a way to get the ‘MAX’ date in a Calculated field. I prefer to not use scripting .
I am using IOS (I do have Mac also)
Please any help is appreciated.
THanks Bernie
Hi Bernie,
You would have to use a Script for this function.
There’s a function designed for getting the maximum value, but it only works for Number fields right now:
var max_value = record.getMaxOfLinkedFieldForField(linkedFieldID, fieldID);
But you could loop through the linked records manually and pick out the largest date value.
Sorry it can’t be done with a Calculation field though.
Here’s an example script that would do what you want:
function getMaxDate() {
var orders_id = 'fld-41443e967b3c4bdd8e258eabef7ffc8c';
var date_id = 'fld-3604363a4c07424294113852f4b3651e';
var orders = record.getFieldValue(orders_id);
var largest_date;
for (var index = 0, count = orders.length; index < count; index++){
var date = orders[index].getFieldValue(date_id);
if (date) {
// do something
if (largest_date == undefined || largest_date.getTime() < date.getTime()) {
largest_date = date;
}
}
}
return largest_date;
}
getMaxDate();
You would need to replace the fld-....
parts with the field IDs of your own fields though.