Can anybody give me a script that reads the EXIF date of a photo (used in field “photo”) and puts this date to an separate field “date”?
I want the entries to be ordered by the date of the photos, that are used in the records.
THABK YOU!
Following field script should do the trick. It assumes that the field name is photo. Don’t forget to set the return type of the field script to date.
function First_Photo_Date() {
// set field name according to your form
var photo_id = form.getFieldNamed('photo').getId();
// get attached photos
const photos = record.getFieldValue(photo_id);
// get first photo's date
const photoExif = photos[0].getExifData(photos[0]);
const photoDate = photoExif['DateTimeOriginal'];
// handle Exif date format
const [datePart, timePart] = photoDate.split(" ");
const [year, month, day] = datePart.split(":").map(Number);
const [hour, minute, second] = timePart.split(":").map(Number);
// create date object
const date = new Date(year, month - 1, day, hour, minute, second);
return date;
}
First_Photo_Date();
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks