# How to use cloud\_username as filter for layer?

**URL:** https://community.qfield.org/t/how-to-use-cloud-username-as-filter-for-layer/1374
**Category:** Ask the Community
**Created:** [6 December 2025 12:00 UTC](https://community.qfield.org/t/how-to-use-cloud-username-as-filter-for-layer/1374 "2025-12-06T12:00:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jeroen-GroeneBij](https://dub1.discourse-cdn.com/flex018/user_avatar/community.qfield.org/jeroen-groenebij/32/905_2.png) [@Jeroen-GroeneBij](https://community.qfield.org/u/Jeroen-GroeneBij)
#### Post date: [6 December 2025 12:00 UTC](https://community.qfield.org/t/how-to-use-cloud-username-as-filter-for-layer/1374/1 "2025-12-06T12:00:57Z")

</div>

Hi all,

I would like to use @cloud\_username to filter the layer that is set as geofencing layer. This way I can create a dynamic geofence. Consider a polygon layer with suburbs. A project manager can fill an attribute ‘surveyor’ with usernames and set a filter to that layer (“surveyor = @cloud\_username )This layer is set as the Geofencing layer. So user 1 is assigned to suburb a, user 2 to b etc.

Now, when a user opens the project in the QFied app the Geofence is applied based on the username.

However: QGIS filter does not use variables as input. This is a feature request since 2017: [Allow qgis variables in provider filter · Issue #24662 · qgis/QGIS · GitHub](https://github.com/qgis/QGIS/issues/24662)

Is there another way to use variables as filter?

Is there another way to prevent users from editing outside their designated ‘area’?

---

<div class="post-metadata">

### Author: ![Jeroen-GroeneBij](https://dub1.discourse-cdn.com/flex018/user_avatar/community.qfield.org/jeroen-groenebij/32/905_2.png) [@Jeroen-GroeneBij](https://community.qfield.org/u/Jeroen-GroeneBij)
#### Post date: [8 December 2025 09:15 UTC](https://community.qfield.org/t/how-to-use-cloud-username-as-filter-for-layer/1374/2 "2025-12-08T09:15:20Z")

</div>

I am looking into a possible workaround:

Consider the polygon layer with suburbs. I add two new fields, surveyor and active. The field surveyor is populated by the project manager with cloud usernames: user1 for suburb a, user2 for suburb b, etc

The field active is a boolean type which has Default set as “surveyor” = @cloud\_username

Then, a filter can be applied with the expression “active” = TRUE

However, this will only work when ”active” is being updated on opening the project in QField. I have not found a way for this to happen yet. I can set the field active to Apply default value on update, but I am not updating this layer as a QField user, I am only opening the project.

Is there some kind of trigger that will update the field “Active” on opening the project in QField? And then apply the filter as next step?

---

<div class="post-metadata">

### Author: ![fggs-pascal](https://dub1.discourse-cdn.com/flex018/user_avatar/community.qfield.org/fggs-pascal/32/732_2.png) [@fggs-pascal](https://community.qfield.org/u/fggs-pascal)
#### Post date: [8 December 2025 10:39 UTC](https://community.qfield.org/t/how-to-use-cloud-username-as-filter-for-layer/1374/3 "2025-12-08T10:39:13Z")

</div>

Hi! I unfortunately haven’t worked with filters so far, but you can set up expression-based permissions for a layer, which might give you the result you want.

If I remember correctly, the example below would make it so that a feature can only be edited if the @cloud\_username matches the value in the field “user”, when put in “Disable attribute editing”, “Disable feature deletion”, and “Disable geometry editing”.

 ![image](https://europe1.discourse-cdn.com/flex018/uploads/qfield/original/1X/eda9b9c31d6b9236f7946f0db2d11c72384a2459.png)

---

<div class="post-metadata">

### Author: ![Jeroen-GroeneBij](https://dub1.discourse-cdn.com/flex018/user_avatar/community.qfield.org/jeroen-groenebij/32/905_2.png) [@Jeroen-GroeneBij](https://community.qfield.org/u/Jeroen-GroeneBij)
#### Post date: [8 December 2025 12:38 UTC](https://community.qfield.org/t/how-to-use-cloud-username-as-filter-for-layer/1374/4 "2025-12-08T12:38:45Z")

</div>

interesting idea.

It does work when I set the ‘user’ per feature. That is however not what I am looking for, I want to set it so a user can only edit a point feature laying within a certain polygon.

I tried overlay\_within(‘polygonlayer’, filter:= surveyor != @cloud\_username)

Here I run into the same issue that a filter expression does not work with variables.  
If I use a hardcoded value in stead of @cloud\_username it does work. This unfortunately is not the solution, because it no longer is dynamic.

---

<div class="post-metadata">

### Author: ![Jeroen-GroeneBij](https://dub1.discourse-cdn.com/flex018/user_avatar/community.qfield.org/jeroen-groenebij/32/905_2.png) [@Jeroen-GroeneBij](https://community.qfield.org/u/Jeroen-GroeneBij)
#### Post date: [9 December 2025 12:17 UTC](https://community.qfield.org/t/how-to-use-cloud-username-as-filter-for-layer/1374/5 "2025-12-09T12:17:16Z")

</div>

I have created a workaround. See this topic in Advanced Use and Customization:

> [@Set user permissions per user per area](https://community.qfield.org/t/set-user-permissions-per-user-per-area/1378):
>
> Hi there, I was looking for a way to prevent users to update features outside a designated area. The idea is to use the cloud\_username variable as defining value. A cloud username is assigned to a certain area by a project manager so that user can only update features or add new features, etc. within that area. My first idea was to use the Geofencing option and apply a filter to the geofencing layer. However, that doesn’t work. QGIS can not handle variables in a filter statement. So, here is…
