<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:"Franklin Gothic Book";
        panose-1:2 11 5 3 2 1 2 2 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 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;}
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;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Ballongtext Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
span.E-postmall17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-postmall18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
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;}
span.BallongtextChar
        {mso-style-name:"Ballongtext Char";
        mso-style-priority:99;
        mso-style-link:Ballongtext;
        font-family:"Tahoma","sans-serif";
        color:black;
        mso-fareast-language:EN-US;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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"><span lang="EN-US" style="color:#1F497D">No, it’s no big deal. That’s why we are using it. And it’s only one time per qgis session.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Franklin Gothic Book","sans-serif";mso-fareast-language:SV">Karl-Magnus
</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Franklin Gothic Book","sans-serif";mso-fareast-language:SV"><o:p></o:p></span></p>
<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>Casper Bertelsen<br>
<b>Skickat:</b> den 22 augusti 2017 14:34<br>
<b>Till:</b> qgis-user@lists.osgeo.org<br>
<b>Ämne:</b> Re: [Qgis-user] Updating a field set with default global variable on edit<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi too,<br>
<br>
Well logging into the QGIS-project should really be a big deal right ? - You only have to log in once no matter how many layers are loaded from the database. I have a table inside my QGIS project where I can create new users inside the database and administer
 reading/writing/admin-privileges.<o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-family:"Tahoma","sans-serif""><br>
Mvh. / Best regards</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-family:"Tahoma","sans-serif"">Casper Bertelsen</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal">On 22/08/2017 13:34, 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_Reply"><span style="color:#1F497D">Hi!</span></a><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">I’ve made the same things with triggers in the database. To avoid getting same username I’ve chosen not to save the username and password in the project. But then the user have to enter it every
 time the projects opens. If you can find a solution to your suggested approach it would be nice.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"> </span><o:p></o:p></p>
<div>
<p class="MsoNormal"><b><span style="font-size:10.0pt">Karl-Magnus </span></b><o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="color:#1F497D"> </span><o:p></o:p></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";mso-fareast-language:SV">Från:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";mso-fareast-language:SV"> Qgis-user [<a href="mailto:qgis-user-bounces@lists.osgeo.org">mailto:qgis-user-bounces@lists.osgeo.org</a>]
<b>För </b>McDonaldR<br>
<b>Skickat:</b> den 22 augusti 2017 13:12<br>
<b>Till:</b> <a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a><br>
<b>Ämne:</b> [Qgis-user] Updating a field set with default global variable on edit</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">Hi List,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB" style="background:white">Anyone know how to update a field that has a global variable set as the default value when records are edited (geometry and/or attributes)?</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"><br>
<span style="background:white">We have a QGIS project with a PostGIS layer loaded and configured with look-ups and relations so the users can update all the relevant fields. There are also "<b>created_by</b>" and "<b>updated_by</b>" fields. These are updated
 by a trigger in the database with the "<b>current_user</b>" database variable. This works fine if you are the current user that added the layer to the project - the trigger works perfectly.
</span><br>
<br>
<span style="background:white">If you give the project to someone else and they create and edit features in the layer the fields are still updated with your name as you are the person who added the layer to the project. Not what we want.</span><br>
<br>
<span style="background:white">QGIS has global variables and there are some new ones -
<b>user_account_name</b> and <b>user_full_name</b> that can be set as default values for the fields. When a new feature is created the field is populated with the correct name. Which is what we want.</span><br>
<br>
<span style="background:white">However, when we update an existing record we'd like the "<b>updated_by</b>" field to be updated with the current "<b>user_account_name</b>". Like a trigger in the database would do on update. Then we would have a better idea
 of the history of the feature.</span></span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB" style="background:white"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB" style="background:white">Ross</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><b><span lang="EN-GB" style="font-size:10.0pt">Ross McDonald |
</span></b><span lang="EN-GB" style="font-size:10.0pt">GIS Data Coordinator | Angus Council, People, IT | Angus House, Orchardbank Business Park, Sylvie Way, Forfar DD8 1AT<b> | t: 01307 476419</b></span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Arial","sans-serif"">This message is strictly confidential. If you have received this in error, please inform the sender and remove it from your system. If received in error you may
 not copy, print, forward or use it or any attachment in any way. This message is not capable of creating a legal contract or a binding representation and does not represent the views of Angus Council. Emails may be monitored for security and network management
 reasons. Messages containing inappropriate content may be intercepted. Angus Council does not accept any liability for any harm that may be caused to the recipient system or data on it by this message or any attachment.
</span><o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:SV"><br>
<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>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:SV"><o:p> </o:p></span></p>
</div>
</body>
</html>