This is a twofold issue. I'm collecting pictures with QField and trying to rename them using this expression 'DCIM/' || "fid" || '_' || format_date(now(),'yyMMdd_hhmmss') || '.jpg' in the QField panel of the layer properties. The first issue is that I want to use the "fid" field of a geometry layer, while the Photo naming settings for Qfield are those ones of the related table (where there is another "fid" fields).

The second issue is that although the expression appears correct, pictures are named like


as in this question, not even considering the "fid" of the table layer.

The naming should work also in case of more than one person working at the same time on the field and adding features and taking pictures simultaneously. The project is successively updated via Qfield Cloud to participant's devices.

2 Answers 2


Taking the second issue first, I think this is the default naming configuration, which is being used because your expression is not working.

So, back to your expression. You want to use "fid" of the parent, geometry layer. In order to use the "fid" of the parent, geometry layer, you need to: (1) get the feature; and (2) access its attributes. As follows:



  • mylayer is the geometry layer you want to access
  • mylayer_pk is the primary key of that layer
  • photo_fk is the foreign key in the photo layer (which should equal the primary key of the geometry layer).

So your entire expression would looks something like

'DCIM/' || attributes(get_feature('mylayer','mylayer_pk',"photo_fk"))['fid'] || '_' || format_date(now(),'yyMMdd_hhmmss') ||  '.jpg'
  • It do works. I should have read better one of your answers. But apparently only if the feature is saved and then edited. Taking the picture at the same time of adding the new feature gives back the old default numbering. Something similar to what already stated here. I've also activated the Fast Editing Mode as suggested but anything changes. Any idea?
    – HyPhens
    Commented Jun 15, 2022 at 8:04
  • For me, it works both for new and existing features. Can you prepare a project file so I can look more closely?
    – Oisin
    Commented Jun 15, 2022 at 10:28
  • Should your proposal still be valid, let me know how to transfer you the project. The expression I've set works only if one person at the time adds features, otherwise in the final project the features will have sequential numbers but different pictures will have the same "fid" as it seems not to be synchronized with field editing...
    – HyPhens
    Commented Jun 16, 2022 at 14:40
  • If you want to share a project then you'll need to use a cloud based service such as dropbox and post a link. But note...QField photo naming works on creation (of the photo) only. So if you edit your "fid" field, the photo name will not change. To do this, you would need to write some code, e.g. in python, but this could not be used in QField, you'd need to do this from QGIS.
    – Oisin
    Commented Jun 17, 2022 at 11:43
  • Yes, you're right, maybe it's an issue that goes beyond the app features by now. Basically, if you think of several operators working with QF simultaneously, they're workin on a local copy of the data. And so several "fid 1", "fid 2" etc., points will be created and the pictures named after that. When everything is downloaded on the pc desktop, feature's "fid" are renamed as unique, but pictures are not. So, probably a different naming strategy should be found, or everyone should synchronize the project immediately after and later adding a new feature...
    – HyPhens
    Commented Jun 18, 2022 at 15:38

Going back to your original post...

If the feature is not saved, the fid is "null" and it will not know what to assign it, thus it will use the default naming.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.