Do you want to control the exact naming of image files submitted through a Survey123 form? It is possible! Using an XLSForm expression, you can set meaningful file names to photos and signatures collected via the Survey123 web and field apps.
The concept
Look at the screenshot below. Note how the file name of the photo has been automatically set to combine previously entered information: The Job ID and Service Type.
You can set the file name of photos, but also signatures. For example, in a Building Permit Application form you may want to compose the file name of a signature using the full name of the requestor plus the exact date and time when the application is submitted.
Having full control over the file names uploaded into ArcGIS is particularly beneficial when you plan to download your data, including attachments, in the future.
The XLSForm basics
To control the name of the files you upload from Survey123 into ArcGIS, you need to use the fileName parameter in the bind::esri:parameters column, as shown below.
Here are some examples:
The name of a photo combines the job ID, type and the current time.
The name given to the signature image file combines the inspector full name with the current time.
Rules and tips
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.
- If you want users to upload more than one photo using a single image question in your form, use the multiline appearance. More details here. When using the multiline appearance, the time stamp suffix alone will make every file name unique.
- If you want to extract and store the file name into a separate field, use a calculation
- On supported in the mobile app: If you want to show or hide the file name to end users, use the fileNameVisible parameter. Similarly, the allowRename parameter is used to control if the file name is shown as read-only or not. You can combine fileNameVisible. allowRename and fileName properties by adding a space between them:
fileName=concat("Student_Photo_", $(first_name},"_",${last_name}) fileNameVisible=false
fileName=concat("Student_", $(fullname}) fileNameVisible=true allowRename=false
Read the Customize file names section of this help topic to learn more.