Hi List,

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)?

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 
"created_by" and "updated_by" fields. These are updated by a trigger in the 
database with the "current_user" database variable. This works fine if you are 
the current user that added the layer to the project - the trigger works 
perfectly.

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.

QGIS has global variables and there are some new ones - user_account_name and 
user_full_name 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.

However, when we update an existing record we'd like the "updated_by" field to 
be updated with the current "user_account_name". Like a trigger in the database 
would do on update. Then we would have a better idea of the history of the 
feature.

Ross

Ross McDonald | GIS Data Coordinator | Angus Council, People, IT | Angus House, 
Orchardbank Business Park, Sylvie Way, Forfar DD8 1AT | t: 01307 476419


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.
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to