<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"Franklin Gothic Book";
        panose-1:2 11 5 3 2 1 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML - förformaterad Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.E-postmall18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTML-frformateradChar
        {mso-style-name:"HTML - förformaterad Char";
        mso-style-priority:99;
        mso-style-link:"HTML - förformaterad";
        font-family:Consolas;
        color:black;
        mso-fareast-language:EN-US;}
span.E-postmall21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="SV" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><a name="T_Default_Reply"><span style="color:#1F497D">Thanks. Works perfect.
</span></a><span lang="EN-US" style="color:#1F497D">I  missed the ”initially deferred” in the FK.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Franklin Gothic Book","sans-serif";mso-fareast-language:SV">Karl-Magnus</span></b><span style="font-size:10.0pt;font-family:"Franklin Gothic Book","sans-serif";mso-fareast-language:SV"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:SV">Från:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext;mso-fareast-language:SV"> Qgis-user
 [mailto:qgis-user-bounces@lists.osgeo.org] <b>För </b>Matthias Kuhn<br>
<b>Skickat:</b> den 4 juni 2019 11:27<br>
<b>Till:</b> qgis-user@lists.osgeo.org<br>
<b>Ämne:</b> Re: [Qgis-user] Forms, realtions and foreign keys<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hello,<o:p></o:p></p>
<p>If you enable "evaluate default values server side" and "automatic transaction groups" and set the foreign key check in the database to initially deferred you'll get pretty much what you want :)<o:p></o:p></p>
<p>Hope that helps<o:p></o:p></p>
<p>Matthias<o:p></o:p></p>
<div>
<p class="MsoNormal">On 6/4/19 11:14 AM, Karl Magnus Jönsson wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><a name="T_Default_New">Hi list!</a><o:p></o:p></p>
<p class="MsoNormal">I have a project with tree tabels stored in PostGIS. <span lang="EN-US">
One is holding the geometry the other two is holding data related to the first table as child and grandchild. I have set up foreign keys between the tables in the database to be sure that there will be no orphan records. In QGIS there are relations and (sub)forms.
 When I digitize a new geometry I get the new id from the database (before it’s saved, OK) in the form but I can’t add any children. I get a database error that says that there are no parent with that ID (and that’s true). I have to  press OK to create the
 feature in QGIS, change tool to identify, find the feature and klick on it to open the form again. Then I can add children. But I haven’t saved so there is still no parent. But it works then. It’s the same with the grandchild table but then the grandparent
 form is still open so it’s not such a big problem. Anyone got a better way to skip this closing and reopening of the form in the workflow?</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt">Karl-Magnus Jönsson</span></b><span style="font-size:10.0pt"> | Gis-Utvecklare<br>
Geografisk information<br>
Miljö- och samhällsbyggnadsförvaltningen<br>
Kristianstads kommun<br>
Besöksadress: Västra Storgatan 12<br>
Postadress: 291 80 KRISTIANSTAD<br>
Telefon: 044-135416 | Mobil: 0733-135416<br>
E-post: </span><a href="mailto:Karl-Magnus.Jonsson@kristianstad.se"><span style="font-size:10.0pt">Karl-Magnus.Jonsson@kristianstad.se</span></a><span style="font-size:10.0pt">
<br>
</span><a href="http://www.kristianstad.se/"><span style="font-size:10.0pt">www.kristianstad.se</span></a><o:p></o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:SV"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt">Läs mer om hur vi hanterar dina personuppgifter på
</span><a href="http://www.kristianstad.se/personuppgifter"><span style="font-size:10.0pt">www.kristianstad.se/personuppgifter</span></a><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:SV"><br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>Qgis-user mailing list<o:p></o:p></pre>
<pre><a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><o:p></o:p></pre>
<pre>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></pre>
<pre>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></pre>
</blockquote>
</div>
</body>
</html>