Username metadata returns “username not found” in webforms – preventing user-based access control

I’m building a centralized KoBo form that is used by multiple teams across different countries. The goal is to automatically control what users can see and submit based on their KoBo account, without relying on any manual user input.

What I’m trying to do

  • Capture the logged-in KoBo username using the username metadata (type = username).

  • Use pulldata() from a CSV file to map each username to:

    • an assigned country / role, and

    • related contact information.

  • Based on that mapping:

    • restrict country-level users to their own country, and

    • allow regional/admin users to access all countries.

  • Display a small “User information” section in the form showing the detected user and assignment.

This approach is meant to avoid human error (e.g. users selecting the wrong country manually).


What worked initially

Earlier during testing, the username metadata correctly returned the actual logged-in username, and the pulldata() mapping worked as expected.


The issue

Currently, for all users, the username metadata always resolves to the literal string:

username not found

This happens even when:

  • the user is logged in,

  • the form is opened via Data → Add submission (not Preview),

  • the project is not anonymous,

  • the form is not accessed via a public link.

Because of this:

  • ${enumerator_username} never contains the real username,

  • all pulldata() lookups fail,

  • user-based access control inside the form becomes impossible.

I confirmed this using debug notes inside the form.


Why this is a problem

Manual user selection (e.g. “Select your name” or “Select your country”) is not a safe workaround, because:

  • it is prone to user error,

  • it defeats the purpose of automatic access control,

  • the form is meant to be centrally managed.


Questions for the community

  1. Under what conditions does the username metadata return “username not found” in KoBo webforms?

  2. Is this expected behavior due to:

    • privacy or security settings?

    • project configuration?

    • Enketo authentication context?

  3. Is there a supported way to reliably access the logged-in username in webforms?

  4. Have others implemented user-based access restrictions within a single KoBo project?

Any guidance or pointers would be greatly appreciated.

Welcome to the community, @rifatzahir! It seems like if you subscribe to a Team’s Plan, then you could achieve this within the system. For more details, feel free to reach us through support@kobotoolbox.org. We would be happy to provide you with more details there.