<div dir="ltr">Hi All, <div><br></div><div><br></div><div>to get field updates on vector layer edits (be they geometry or attribute edits) you can use the AutoFields plugin [1]. You can use expressions just like you do when setting default values in QGIS.</div><div><br></div><div><br></div><div>Regards, </div><div><br></div><div>Germán</div><div>-----------</div><div>[1] <a href="http://geotux.tuxfamily.org/index.php/en/geo-blogs/item/333-autofields-plugin-for-qgis">http://geotux.tuxfamily.org/index.php/en/geo-blogs/item/333-autofields-plugin-for-qgis</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-22 8:45 GMT-05:00 Casper Bertelsen <span dir="ltr"><<a href="mailto:casperbj94@gmail.com" target="_blank">casperbj94@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<font face="Tahoma">Hi Ross,<br>
<br>
If you make your project without saving username and password, the
project will prompt for a user and password when opened. Then each
member can login using their assigned login and thus making it
possible to use current_user in postgres.<br>
<br>
To remove saved username and password from your current project
file (make a copy, beforehand), you can open it in a text editor
and seach for <layername> untill you find <br>
<br>
<font color="#ff0000"><datasource>dbname='xx' host=yy
port=5432 <font color="#000000">four lines above
<layername></font></font></font><font face="Tahoma"> and
remove the username and password-part only .<br>
<br>
<br>
</font><span class="">
<div class="m_-4918899306657143252moz-signature"><font face="Tahoma"> Mvh. / Best regards</font><br>
<div class="m_-4918899306657143252moz-signature"><font face="Tahoma"> </font><font face="Tahoma">Casper Bertelsen</font><br>
<div class="m_-4918899306657143252moz-signature"><font face="Tahoma"> <br>
</font></div>
</div>
</div>
</span><div><div class="h5"><div class="m_-4918899306657143252moz-cite-prefix">On 22/08/2017 15:36, McDonaldR wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div class="m_-4918899306657143252WordSection1">
<p class="MsoNormal"><span style="color:#1f497d">Thanks
Karl-Magnus<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">We use triggers
in the database already and they work perfectly but if we
want to record the specific user creating and editing
features then we’d have to create separate projects for each
user. At the moment the team of about 10 users all use a
set of centrally stored project files – one for each
different task.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">I found this
post on Stackexchange (<a href="https://gis.stackexchange.com/questions/217011/how-to-automatically-update-wfs-edits-with-a-user-id" target="_blank">https://gis.stackexchange.<wbr>com/questions/217011/how-to-<wbr>automatically-update-wfs-<wbr>edits-with-a-user-id</a>)
where global variables are used to populate fields when
features are added. However, as Matthias notes in the
comments this doesn’t work on feature “update”. If this
were possible then it would meet all our needs. Maybe
something that could be funded?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">Ross<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></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"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> Karl Magnus Jönsson
[<a class="m_-4918899306657143252moz-txt-link-freetext" href="mailto:Karl-Magnus.Jonsson@kristianstad.se" target="_blank">mailto:Karl-Magnus.Jonsson@<wbr>kristianstad.se</a>] <br>
<b>Sent:</b> 22 August 2017 12:34<br>
<b>To:</b> McDonaldR; <a class="m_-4918899306657143252moz-txt-link-abbreviated" href="mailto:qgis-user@lists.osgeo.org" target="_blank">qgis-user@lists.osgeo.org</a><br>
<b>Subject:</b> SV: [Qgis-user] Updating a field set
with default global variable on edit<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><a name="m_-4918899306657143252_T_Default_Reply"><span style="color:#1f497d" lang="SV">Hi!</span></a><span style="color:#1f497d" lang="SV"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US">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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><b><span lang="SV">Karl-Magnus
</span></b><span lang="SV"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="color:#1f497d" lang="SV"><u></u> <u></u></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"" lang="SV">Från:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="SV"> Qgis-user [<a href="mailto:qgis-user-bounces@lists.osgeo.org" target="_blank">mailto:qgis-user-bounces@<wbr>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" target="_blank">qgis-user@lists.osgeo.org</a><br>
<b>Ämne:</b> [Qgis-user] Updating a field set with
default global variable on edit<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="SV"><u></u> <u></u></span></p>
<p class="MsoNormal">Hi List,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span 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)?<u></u><u></u></span></p>
<p class="MsoNormal"><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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="background:white"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="background:white">Ross</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b><span>Ross
McDonald |
</span></b><span>GIS
Data Coordinator | Angus Council, People, IT | Angus House,
Orchardbank Business Park, Sylvie Way, Forfar DD8 1AT<b> |
t: 01307 476419<u></u><u></u></b></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><span> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span 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><u></u><u></u></p>
</div>
</div>
<div> </div>
<div>
<p class="MsoNormal" style="MARGIN:0cm 0cm 0pt"><span><font size="2">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.<span>
</span>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.
</font></span></p>
</div>
<br>
<fieldset class="m_-4918899306657143252mimeAttachmentHeader"></fieldset>
<br>
</div></div><span class=""><pre>______________________________<wbr>_________________
Qgis-user mailing list
<a class="m_-4918899306657143252moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a>
List info: <a class="m_-4918899306657143252moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="m_-4918899306657143252moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a></pre>
</span></blockquote>
<br>
</div>
<br>______________________________<wbr>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>-----------<br></div><div> |\__ <br>(:>__)(<br> |/ <br>Soluciones Geoinformáticas Libres <br><a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br><a href="http://twitter.com/GeoTux2" target="_blank">http://twitter.com/GeoTux2</a></div><div><a href="http://about.me/germancarrillo" target="_blank">http://about.me/germancarrillo</a><br></div><div><div><br></div><div><a href="http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo" target="_blank"><img src="http://gis.stackexchange.com/users/flair/4972.png"></a></div></div></div></div></div></div></div>
</div>