Renaming images with bind::esri:parameters - get photo creation date?

378
3
10-18-2022 12:53 PM
Joshua_Damron
New Contributor

Howdy,

I have a survey with 3 image uploads, no repeats are being used.  The names used for these in the xlsform are photo1, photo2, photo3.  I am using the Survey123 mobile app version 3.15.159 for Android.     I would like to build the unique image names from the date/time  of the images creation, below are the issues I have encountered:     1) I found that the bind::esri:parameters is not compatible with pulling the date/time from the image file like this:    

fileName=concat(${Record_ID} ,"_", format-date(pulldata("@exif",${photo2}, "DateTime"),'%Y%m%d%H%M%S'))

Am I doing something wrong with the above or is this a known issue?

 

2) As a 2nd best option I tried using now() to give each image a unique ID however I found that now() doesn't refresh between image uploads.  Meaning that this formula was not unique between the images uploaded:

fileName=concat(${Record_ID} ,"_",format-date(now(),'%Y%m%d'),"-",format-date(now(),'%H%M%S'),"_",substr(pulldata('@property','userFirstName'), 0,2),pulldata('@property','userLastName'))

3) Since those didn't work out, for the moment I am hardcoding a 1/2/3 into the file name for each photo field to force distinct names:

photo1:

fileName=concat(${Record_ID} ,"_",format-date(now(),'%Y%m%d'),"-",format-date(now(),'%H%M%S'),"-1_",substr(pulldata('@property','userFirstName'), 0,2),pulldata('@property','userLastName'))

photo2:

fileName=concat(${Record_ID} ,"_",format-date(now(),'%Y%m%d'),"-",format-date(now(),'%H%M%S'),"-2_",substr(pulldata('@property','userFirstName'), 0,2),pulldata('@property','userLastName'))

 

4) To tack on another issue I found, I was not able to retrieve just the first initial of the users first name using this: 

 substr(pulldata('@property','userFirstName'), 0,1)

So instead I am retrieving the first two letters of the name with this:

 substr(pulldata('@property','userFirstName'), 0,2)

 

Any assistance is appreciated 🙂

 

 

 

Tags (2)
0 Kudos
3 Replies
DougBrowning
MVP Esteemed Contributor
0 Kudos
Joshua_Damron
New Contributor

Thanks for the catch!  ImageDateTime is correct.  You got me excited there...

Unfortunately it is looking like the survey doesn't pull in the image exif data until after the image has been saved... meaning that when use the formulas below where I am duplicating the fileName expression in both photo1 and photo2: it fails to pull the ImageDateTime for photo1 but successfully pulls the ImageDateTime of photo1 for photo2.

Photo1

fileName=concat(${Record_ID} ,"_", format-date(pulldata("@exif",${photo1}, "imageDateTime"),'%Y%m%d%H%M%S'))

Photo2

fileName=concat(${Record_ID} ,"_", format-date(pulldata("@exif",${photo1}, "imageDateTime"),'%Y%m%d%H%M%S'))

DougBrowning
MVP Esteemed Contributor

Maybe a if(check for no photo, dont do anything, calc name) ?

Other idea is the new calculation modes and set that to always.

0 Kudos