More User Friendly Image names for images uploaded through app

When images are uploaded through an Appsheet app form, the Appsheet names images files in the format [Table’s Key column].[Image Column Name].[TimeStamp] that are cryptic at times for users.

Instead of saving images in the “Parent” table, if the app creator can have a three-column child table to the “Parent” table to save images, the images could have meaningful name strings.

Columns in this child table will be [ID ] - Key column, [Parent Table ID] - Reference to “Parent” table and Image Column called say [IMG] .

The initial expression for the key column of the child table can be something as below and it could also be populated through a LINKTOFORM() action during the parent record save. Parent Fileds are the fields that we wish to include in the file name string.

CONCATENATE([Ref Column].[Parent Field 1] ,"-", [Ref Column].[Parent Field 2] ,"-", [Ref Column].[Parent Field 3] , RANDBETWEEN(1111,9999))

RANDBETWEEN() or UNIQUEID() can be used to bring uniqueness to the key.

Then create a LINKTOFORM() action on the parent “Parent” record save event to prepopulate child record with reference column and child table key with the above-suggested CONCATENATE() expression’s pattern.

LINKTOFORM(
“Child Table Form”, “Child Table Key Column”, CONCATENATE(Parent Field 1] ,"-", [Parent Field 2] ,"-", [Parent Field 3], RANDBETWEEN(1111,9999)),

“Ref Column in Child Table”, [Parent Key]
)

Then the saved image file names will have an initial string from the parent table fields as desired.

An example below

Parent Record. We wish to populate image file name string with [MainType], [Type] and [Name]

On saving the above parent form, it takes to child form through LINKTOFORM() action. The key of the child record is prepopulated with the desired fields from the parent table

The back end Google sheets looks like below

Parent Table back end

Child table back end.

The portion highlighted in blue adds the desired string to the file name. The portion highlighted in orange is the default file naming convention followed by AppSheet.

Inline gallery view of images will also look better with more meaningful image names

Hope this makes sense.

Edit: Minor edits in description.

12 Likes

I like this :+1:t2:

2 Likes

Nice setup.

2 Likes

Hi Sir

I found this very helpful but stuck on the way following the instructions:

This is query is what I have defined in my child (photo) table:

CONCATENATE([Site Inspection].[Job No.] ," ", [Site Inspection].[CMR Reference] ,"-", [Site Inspection].[Schedule] ,"-" , RANDBETWEEN(1111,9999))

I am not sure where this LINKTOFORM() query should be placed in the parent table (in my case - would be “Site Inspection table”)?

Note that each one of my parent record (site inspection) can hold a list of multiple child photos so the App Formula seems to have been occupied by the system already.

Thanks :slight_smile:

Hi @AndyYang ,

The LINKTOFORM() is a navigation action and it is optional in this implementation. It takes the user to the child table form on parent form save.

If you save the parent record first and then add children records , then the LINKTOFORM() action is not required. Anyway, please take a look at actions and LINKTOFORM() action based sample app.

https://www.appsheet.com/templates/This-app-shows-how-to-link-to-a-form-and-fill-in-default-values?appGuidString=ad497f8e-7d8a-4664-8a4a-43c202bb6126

One thing to note is that the field names from the parent ( [Job No], [CMR Reference] and [Schedule] in your case) should be stable fields. This means these are not often changing enum/ enumlist / date time fields such as [Status], [Progress], [Status Date], etc. because the child key and hence image file name is built based on these fields. If these fields values are changed after saving images, the image file name will not change, even though the images will remain referenced to the parent record.

4 Likes

Hi @Suvrutt_Gurjar

Thank you for the detailed explanation on the LINKTOFORM(). Now I know I do not need that.

I have now got the concatenated image name populating correctly like this:
image
-those are just un-editable plain Text-

But my added/uploaded images are still in default random name rather than the customised name above. Here is a snapshot of my current backend file structure:


AppSheet Column view:

I wonder should I set column IMG as type “Image” in AppSheet?

Thanks so much :smiley:

This is brilliant! Thanks @Suvrutt_Gurjar :smiley:

3 Likes

Hi @AndyYang ,

As clearly mentioned in the approach, if “Site Inspection Photo” is a child table of parent table 'Site Inspection", the child table will essentially need only three columns

  1. Key - which is a key column of text type with an initial value expression something like

CONCATENATE([Site Inspection].[Job No.] ," “, [Site Inspection].[CMR Reference] ,”-", [Site Inspection].[Schedule] ,"-" , RANDBETWEEN(1111,9999))

  1. A Ref type column that references the parent “Site Inspection” table

  2. An Image column “IMG” ( any other name will do. Preferably keep it short because it reflects in the image file name) of Image type without any expressions. The user uses this field to upload images thru’ the app.

The image file name will be automatically assigned by the app based on the Key column by the app.

5 Likes

Hi @Suvrutt_Gurjar ,

Thank you for your reply :slight_smile:
I see. The child table can only have 3 columns (Key, Ref, IMG) to get the naming working right. Then we might not be able to make this happen because we have other columns like Description and LatLong. But I really love this tip! Thanks!

You have just misunderstood the point from the beginning.

  • There is only one possible value from your data Table that will be present in the eventual filename.
  • That is the key value.

In general, in your main data Tables, it will not be appropriate to generate a human-readable key value for each record, for the purposes of achieving nice file names. It is not appropriate for many reasons, but that’s a bit beyond the scope of this tip.

Suvrutt’s tip sidesteps that issue by storing photos/files in a separate related Table, which is just for files. In this separate Table, you are more free to create key values that you’d like to see in your filenames, such as a concatenation of multiple values from your main Table.

3 Likes

Hi @Marc_Dillon

Blockquote

I tried to add formula to my current Key column in the child table - but it would not allow me to do so.

What did you mean by free to create key values that I like to see in filenames?

As the error says, “App Formulas” are not allowed for key columns. Because key values cannot be edited once they are created. Use “Initial Value” instead.

I really hope you understand by now that the key value of the record is what is showing up in the filename. So what I mean by “more free” is that the key value in the files-only Table, will have less “restrictions” on it, than on a standard Table of records. By “restrictions” I just mean “best practices” not really actual restrictions.

For example, You really shouldn’t be using something like “Solar System-Planet-Earth-21” as a key value for a standard Table, most experienced app developers will be using a basic UNIQUEID(). But in a Table that is meant solely for keeping files, it’s not a big deal.

3 Likes

Ok I understand that Key values are uniquely created to avoid any identical values or name clash. And yes I already knew that the key value is showing at the beginning of each filename by default. Those key values are the Ref linking back to its Parent Table (Site Inspection)

image

So the conclusion is - I am not able/ allowed to modify key value column as the error message indicated so I cannot have image filename customised in my use case.

Not being able to edit existing key values has no connection to being able to implement Suvrutt’s setup described here. I don’t know what your case is, but I’d imagine this setup would be applicable to pretty much any case, if done correctly. I’d assume you’re still not understanding some part of the core concept here, but I no longer have any idea where that misunderstanding is coming from. :grimacing:

4 Likes

Hi @Suvrutt_Gurjar @Marc_Dillon
Thank you both. I have figured out where I got stuck on…

I put that concatenate query in FORMULA field instead of INITIAL VALUE field so that’s why it kept failing and nothing happened.

Now it works perfectly :smiley: and the child table does not necessarily need to have only three columns. It can have more.

Thank you for the great tip!

2 Likes

Glad you figured it out.
Just some usefull info:

Seriously. Read the whole thing at least twice.
I have read everything except the whole Expression part and Automation, since it’s newer and covers a lot of things that I won’t use.
In general, read as much as you can to understand the basics, and a little more, about the platform.
Thank me later

4 Likes

Good to know you finally got it to work.

If I may add, as @SkrOYC suggested, you may wish to go through AppSheet help articles and even posts thoroughly. With coding / configuring, as we know even one misplaced comma can make a huge difference in final results.

Marc and I mentioned the “Initial value” at least thrice in our respective updates right from the beginning :slight_smile:

Anyway, all the best with your app creation.

3 Likes