Put UserName in a Field

7393
10
Jump to solution
02-17-2017 07:41 AM
JohnMcConalogue
New Contributor III

I want to add the surveyor's username into a field.

How can I pick up the username?

Thanks.

Tags (1)
1 Solution

Accepted Solutions
IsmaelChivite
Esri Notable Contributor

Do something like this:

 

 type name label
usernametheusernameUsername

 

The username question type will capture the currently logged-in user into a field in your layer, but will not be shown in your form.  If you want to show the loggedin username into the form, use a note question as shown below:

 type name label
usernametheusernameUsername
note Username is ${theusername}

 

For completeness, there is an alternative way to get the username using the property('username) function. However, this function only works in the Survey123 field app. At the moment, property('username') does not work in the Survey123 field app.

View solution in original post

10 Replies
JamesTedrick
Esri Esteemed Contributor

Hi John,

The using Survey123Connect, the easiest way to do this is to add a field of type username to the survey- the field will not be visible, but will record the username. Refer to the 'Question Types' section in XLSForm essentials—Survey123 for ArcGIS | ArcGIS   That being said, Survey123 uses a feature call editor tracking (Editor tracking for feature services—Documentation (10.3 and 10.3.1) | ArcGIS for Server ) that automatically records the username (and date & time) of when a survey is submitted.

JohnMcConalogue
New Contributor III

Again, thanks for the reply James.

How can I get the Username to display on the survey though?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

You can use the property function to access the username if you want it in a visible field - see the 'Device and user properties' section in Prepopulate answers—Survey123 for ArcGIS | ArcGIS 

JohnMcConalogue
New Contributor III

Thanks James.

0 Kudos
PeterMacKenzie2
Occasional Contributor II

I tried this but it didn't work -
pulldata("@property", 'username')
how do you put the user name so I can have a message: "you are signed in as" and [esri username]

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Peter,

You can have a question of type 'username' and then use that in a calculation.

AdamDaily
Occasional Contributor II

James,

I don't see a 'username' function under the device and user properties pulldata list. As others note, the username question alone does not display in the survey. I added an additional text question to my survey with a  

Calculation: ${username},  but all it returns is "Unknown @property: username". I am logged into AGOL, but testing through Survey Connect with an unpublished survey.

0 Kudos
IsmaelChivite
Esri Notable Contributor

Do something like this:

 

 type name label
usernametheusernameUsername

 

The username question type will capture the currently logged-in user into a field in your layer, but will not be shown in your form.  If you want to show the loggedin username into the form, use a note question as shown below:

 type name label
usernametheusernameUsername
note Username is ${theusername}

 

For completeness, there is an alternative way to get the username using the property('username) function. However, this function only works in the Survey123 field app. At the moment, property('username') does not work in the Survey123 field app.

CarlHolt1
Occasional Contributor III

If the field is turned to readonly=yes, will it appear in the report?

0 Kudos