Select to view content in your preferred language

Photo fileName= Sporadically Working

176
4
03-15-2025 06:24 PM
GarrettRSmith
Frequent Contributor

Hello All.

Has anyone here run into issues with the fileName= working sometimes and not working other times? I cannot figure out what the issue might be, for context, here is what I am using:

fileName=concat(${photosites},"us-",format-date(today(),%Y%m%d"))

Sometimes I get this result, which is right:

PP4MLO01us-20250315.jpg

Sometimes I get this result, which appears to be tacking on some random numbers at the end:

PP4MLO01us-20250315-012121.jpg

I made my file names try and match the errant ones in the hopes that I can just run some kind of batch processing of the file names to remove the extra characters at the end, but this seems like it would defeat the purpose of trying to create standard files names for the photos people are taking. Also, like I mentioned previously, this seems to be a hit or miss operation in both Connect and on my phone after publishing.

Any help is greatly appreciated.

0 Kudos
4 Replies
TylerGraham2
Frequent Contributor

Esri says: 

Survey123 Tricks of the Trade: Set the file name of photos and signatures

Here are some rules to properly set the file name:

  • Avoid spaces and the following special characters: \ / : * ? < > ; | . , ".
  • The file name must be unique: Otherwise, you will have trouble either attempting to upload, or when you download the file in the future.  
  • Keep file names under 140 characters

If you do not follow the rules above, the Survey123 mobile and web apps will override your file name with one that complies with the rules.

Tips:

  • Always use a time stamp as a suffix to make your file names unique. For example:

fileName=concat("Photo_",format_date(now(),"%y%m%d%H%M%S"))

  • Using a time stamp as a suffix, does not guarantee uniqueness if you have multiple image questions. If your survey includes multiple image questions, add the question name as a prefix to avoid the possibility of duplicates.

     

I would guess that you are ending up with 2 or more photos that are concating to the same file name and it is adding some numbers to keep each photo's file name unique. You might experiment by adding %H%M%S to the date format and see if it has any effect. If it is because of duplicate file name, while going to the second isn't a guarantee that it will be unique, it will probably catch most duplicates.  That is if you aren't just holding down the camera button and taking multiple photos in a second.  

0 Kudos
GarrettRSmith
Frequent Contributor

Hi @TylerGraham2 thank you for the tips. 

I added the %H%M%S to the end of my date format and that seemed to fix one problem. However, now the first photo in each repeat is reverting back to the weird file name that I posted above. For example, for my first repeat  photo file name I get this:

PP4MLO02us-20250317012121.jpg

Then, for the second photo file name in that same repeat I get this:

PP4MLO02ds-20250317-142331.jpg (which is right as it contains the hour, minute, and second).

This is true for all of my repeats, where the first photo taken has a funky name and the other one is correct. If I delete the original photo, with the wrong name and retake it, it will magically contain the correct file name. I am not sure that this is the best way to work with this survey in the field, to trick Survey123 by taking and erasing the first photo taken in the repeat, but if this is the only way that it will work then I suppose I rather have the file name correct than post processing it somehow. 

Thanks again for your help and happy to receive more feedback.

0 Kudos
TylerGraham2
Frequent Contributor

What version is your form?  Your problem sounds similar to this now() function bug.  The workaround is pretty much what you're doing, but it was supposed to be fixed in 3.17. 

BUG-000152458 for ArcGIS Survey123

If you're up to date on the form, you might try one or both of these ideas. The fastest would be to test it using the today() function in place of now() since you were originally using just the date anyway.  Just keep in mind that if you're taking multiple pictures that would create the same file name, you'll be running into problems with name standardization again.

The other thing you might try is capturing the date and time in a field and passing the field into the fileName parameter instead of directly calling the now() function in the parameter.  

 

0 Kudos
GarrettRSmith
Frequent Contributor

I am using Version 3.22.49

I tried to use now() instead of today() and the issue now happens with both photos on the repeats. I also tried capturing the date and time from a date field, but that gave the same results as using now().

The file names are all unique because each of the sites that are being put into the filename via ${surveysties} have unique names. 

Ohh well, at least there is a work around that is not too much of a pain.

0 Kudos