Show different choices according to username

Hey there,

I understand we can display the ${username} in a Kobo form (as long as the enumerator has logged in with their credentials).

What else can we do with it? What kind of interesting things have you folks done with it?

Here’s my situation:
The enumerator has to select one City.
And then, using choice_filter and an external CSV file (hospitals.csv), I display a list of Hospitals for him to select one. And then, using pulldata, I display additional information (from CSV) about the selected Hospital.

Issues:
#1 Right now, I’m trusting that the enumerator will focus on their City and not snoop on the other cities to see information from other Hospitals.
#2 I’m also trusting that the enumerator will focus on their Hospital and not snoop on the other hospitals from their own city.

How can I prevent enumerators from snooping around?

I understand my CSV could have a column for the username, and then each Hospital would have a username assigned to it. And I could choice_filter through that. That could work! But… my CSV file is being exported from a system that doesn’t know anything about Kobo usernames, and the CSV file will be updated from to time (it’s not permanently static). And I don’t want to manually add the usernames, so I can’t count on this.

Is there a workaround?
Can we use other information from the Username’s KoboToolbox web profile?
I see many fields, including City.

So I could at least solve Issue #1.

Which avenues should I explore?

Thank you so much!

@ivanradisson, maybe you could use the username form metadata with the pulldata as shown in the image shared below:

In the survey tab of your XLSForm:

CSV file:

Image 2

Configure your Collect app’s Metadata:

The username should match the name in CSV file.

Screen as seen Collect android app:

Here the username is pulled automatically. You need not type the name manually.

Screen as seen Collect android app:

These are the details pulled automatically by the pulldata function.

Reference XLSForm:

Pull Data (Username).xls (33 KB)

CSV file:

Codes.csv (145 Bytes)

With this approach, you will not need to filter the details like you generally do with the cascading select. The pulldata function helps to filter out all the details that are only required which matches the username metadata.

Also please note that this approach best works with Collect android app as you are able to configure Metadata (as outlined in our support article here) that matches the name which you wish to use as names that should filter out the details. You could also use Enketo here but Enketo should pull the account name while using the username hence it only works if the account name matches the username that is being used in the CSV file.

1 Like

Hey there @Kal_Lam ,

I’m very thankful for the fully detailed answer.

But i’m afraid my point was not correctly communicated across the interwebs. I apologize for this.

You see, having the username on the CSV requires me to update the CSV manually, since the CSV is currently being exported from a different system (from time to time, when there are new choices). And up to now, the idea was to import it into Kobo directly (without manual intervention).

That’s why I prompted if there was a different way of achieving what I want. Maybe using one of the other fields in the user Kobo Profile ?

In this case, maybe you could try out the Dynamic Data Attachment as outlined in our support article shared here:

Thank you. I will look into this.

1 Like