<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<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:"Century Gothic";
        panose-1:2 11 5 2 2 2 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";
        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;}
span.E-postmall17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-postmall18
        {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: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 lang="SV" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><a name="T_Default_Reply"><span style="color:#1F497D">Hi!<o:p></o:p></span></a></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.<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";color:black;mso-fareast-language:SV">Karl-Magnus
</span></b><span style="font-size:10.0pt;font-family:"Franklin Gothic Book","sans-serif";color:black;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";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 [mailto:qgis-user-bounces@lists.osgeo.org]
<b>För </b>McDonaldR<br>
<b>Skickat:</b> den 22 augusti 2017 13:12<br>
<b>Till:</b> qgis-user@lists.osgeo.org<br>
<b>Ämne:</b> [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"><span lang="EN-GB">Hi List,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></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)?<o:p></o:p></span></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.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="background:white"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="background:white">Ross</span><span lang="EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-GB" style="font-size:10.0pt;font-family:"Century Gothic","sans-serif";color:#4F6228;mso-fareast-language:EN-GB">Ross McDonald |
</span></b><span lang="EN-GB" style="font-size:10.0pt;font-family:"Century Gothic","sans-serif";color:#4F6228;mso-fareast-language:EN-GB">GIS Data Coordinator | Angus Council, People, IT | Angus House, Orchardbank Business Park, Sylvie Way, Forfar DD8 1AT<b>
 | t: 01307 476419<o:p></o:p></b></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:SV"> <o:p></o:p></span></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><span lang="EN-GB"><o:p></o:p></span></p>
</div>
</div>
</body>
</html>