I read the documentation, examples and made many attempts, but I still can't make this work.

What I want is to get a value from a parent layer while editing a child layer, when both features are being created in a embedded forms setup. So far, I can't seem to make current_parent_value() and current_value() work in an embedded forms setup.

I'm using QGIS 3.28 (tried with previous versions too) on Windows 10.

Let's say I have two nested forms: Form1 and Form2. Form2 is nested inside Form1 through a Relation. The 'fid' from Form1 and 'rel_id' from Form2 are used with the Relation to link both forms. I'm trying to get the value of 'Total' field from Form1 in Form2.

To try and understand what works and when I did this Case/When with a Coalesce.

when "rel_id" is not null then coalesce(  
else 00000  

The workflow is quite simple:

  1. Create a feature in Form1
  2. From this layer, create a child feature in Form2

enter image description here

In the end, I want my "value" field from the child feature to get the "Total" value from the parent feature. To be clear, this is a dummy project to test the function for something more useful than this.

When I create the feature, I get the '11111' value, which tells me my condition is caught, but no element of the coalesce work. enter image description here

Then, when I update the feature afterward (change the value to trigger the "apply default value on update"), I finally get the right value, which tells me that the regular attribute(get_feature()) works.

enter image description here
enter image description here
enter image description here

But I really can't find a way to get the right value when creating the feature. In the end, I have the good value, but this confuses my users because they see the wrong value when they are working with the form in the field...

What am I doing wrong?

Here is a sample project to test the equation: Here

  • Which new feature function do you mean? To test any answers to you r question, one first has to start to rebuild the exactly same project/data as you have it. From the description it is a bit difficult to understand and, anyway, cumbersome to create an exactly matching project. So to boost your chances to get an answer, I would advice to post a link to a sample project with dummy data so that one can see what you have.
    – Babel
    Commented May 19, 2023 at 15:45
  • 1
    Sorry, there is no feature function in QGIS expressions. You mean get_feature() function? But this is not new.... Anyway - without a sample project or some screenshots, to me the questions remains unclear, even with the additions you made. Don't know why you don't want to post additional information and let people here working to re-create the setting you already have instead of helping them to help you solve your problem...
    – Babel
    Commented May 19, 2023 at 20:17
  • Hi @Babel , calm down, I'm very happy you want to help! I didn't receive any notification after your first comment, that's why my edit yesterday did not bring you the information you needed. I added a linked at the end of my question for you to download a simple project to test the equation. I'm sure I'm doing something wrong and that it can quickly be solved, but I can't seem to figure out what. I also removed the comment about the new "feature" variable (not function, you're right), as I think it's not what I need.
    – Horizen
    Commented May 20, 2023 at 19:07
  • This is what I was referring to, but I realized that it replaced $currentfeature, not current_value(). My bad Feature variable docs.qgis.org/3.28/en/docs/user_manual/expressions/…
    – Horizen
    Commented May 20, 2023 at 19:12
  • By "form" you mean "layer", right? That's a bit confusing. WOuld it not be easier to use a table join? By the way: for fid, you set a default value of rand(1,10000) - you should not do that, Geopackage handles unique fid-values automatically and interfering just complicates things and adds to the confusion about what you intend to achieve.
    – Babel
    Commented May 20, 2023 at 20:36

1 Answer 1


To get

  • the value of the field Total from layer Form1
  • to layer form2,
  • where the rel_id of form2 is identical to the fid from Form1,

use this expression:

attribute (get_feature('Form1','fid',"rel_id"),'Total')

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.