Survey123: Parsing “property('username')” calculation value to get clean user name

17465
20
08-15-2018 04:12 AM
JoeFlannery
Occasional Contributor III

Our users log into ArcGIS Online (AGOL) and Esri’s mobile apps with enterprise credentials.  Our AGOL username is automatically created from our email address and a tag at the end.  Like this:

 

Firstname.Lastname@xyz.com_xyz

 

In Survey123, the AGOL username of the person who logs into the app and submits a completed form can be calculated using the "property('username')" formula.  I would like to have the AGOL username populated in my Survey123 form as input to a question, line like - “Inspected By”.

 

In Survey123 Connect, how do I parse the AGOL username calculated by "property('username')" into a readable name?

 

Firstname.Lastname@xyz.com_xyz  -->  Firstname Lastname

Thank you.

Tags (2)
0 Kudos
20 Replies
JoeFlannery
Occasional Contributor III

Ismael:

 

Thank you for your response.  I see that I have made a mistake in my original question, which crossed between Survey123 Connect and Report Template building in MS-Word.

 

I am working in Survey123 Connect and attempting to use the “property('username')” in the calculation field to populate the Inspected By: slot of my survey form.  The property('username') comes into my form line as expected from our enterprise login username.

username

I would like to format this calculation to be “Joe Flannery” (Firstname-space-Lastname).

 

I am trying to understand MS-Excel formulas for this task just to get my head wrapped about the concept and have gotten as far as using this to parse out the name:

=PROPER(LEFT(E5,FIND("@",E5)-1))

 

At this point, I’m not even sure that I can use an Excel formula like the one above in the Survey123 XLSform.

 

Thank you for your patience as I define my need.

Joe

0 Kudos
JoeFlannery
Occasional Contributor III

This gets me pretty darn close!

Since all of our Survey123 users have an enterprise login with their corporate email address, they all have the same 12 characters after their name.  Here, all I do is keep the text that precedes the last 12 characters to their AGOL user name, albeit, with a dot between first and last name.

excel

connect

0 Kudos
by Anonymous User
Not applicable

Hi Joe, I know this is an old post and most likely you've resolved how to do this for your needs.

But I thought I'd post how I'm doing this using the answer Ismael provided above.

Create a csv file containing 2 columns (name - username) and save this to the media folder of your survey.

In this example the csv is saved as ServicePerson.csv in the media folder of a survey called Water Unit Job Details.

In your survey in Survey123 Connect add a row with a calculation like this.

pulldata('ServicePerson','name','username',property('username')

What this does is...(I find it easiest to read the calculation from right to left)

  1. get the username of the person signed into Survey123 (property('username')
  2. use this to find the row in ServicePerson.csv where the value in the 'username' column is the same as (property('username') - the username of the person signed into Survey123.
  3. Then finally from this matching row in ServicePerson.csv get the value in the name field and use this to populate your field in Survey123.
JoeFlannery
Occasional Contributor III

Well done, Michael!

Thank you for the follow-up response.  I'll give this a try.

Joe

0 Kudos
TI
by
Occasional Contributor II

Does property('username') work when the person taking the survey is not signed in to Survey123?

It will allow collection of data while not signed in and I've found that the 'username' field type will not record the username when not signed in (makes sense, I guess).  It does not add the username when the user signs in to submit the survey.

0 Kudos
by Anonymous User
Not applicable

Please see my reply to your other post here: https://community.esri.com/thread/226878-survey123-username-field-is-null 

Phil.

0 Kudos
by Anonymous User
Not applicable

property('username') returns the signed in username, if the user is not signed in then no value will be returned.

In surveys where I want to ensure submitted info is from signed in users I'll add all survey question into a group then use a relevant expression on the begin group line to only show if the user is signed in.

If the user isn't signed in they'll see the note asking them to sign in, at this point the user can still submit the survey but it will be empty. 

If I want to ensure empty surveys cannot be submitted then I move the SERVICE_PERSON row (in my example) to the top, and make it a required field (normally make it hidden too).

 

TI
by
Occasional Contributor II

This is a reasonable solution in some cases, and I have considered doing something similar to this.

However, a lot of our users will be out of network access while collecting data.  Therefore signing in after commencing survey collection may not be possible (or at least not until after they've returned to the office, which would require them to double-handle the data).

0 Kudos