Select to view content in your preferred language

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

20478
20
08-15-2018 04:12 AM
JoeFlannery
Honored Contributor

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
by Anonymous User
Not applicable

When I sign into Survey123 and download the survey I'm working with then go out of network coverage, property('username') still works even though I have no network connection.

A network connection is needed to sign in, download and send surveys, but the rest of the time Survey123 is effectively working offline.

0 Kudos
TI
by
Frequent Contributor

Yes, that's correct.  The problem in our case is that users get signed out from time to time without their knowing it, and if they are out in the field without any network and signed out, then it is too late to do anything about it.

0 Kudos
by Anonymous User
Not applicable

The reason users are being signed out after a period of time when offline is that, in the current released version of the app (3.1), when the AGO/Portal user login token expires an attempt is made to refresh the token from AGO/Portal to keep the user signed in while the app is active. If the device is offline this token refresh fails and the user is signed out. In the 3.2 release of the app we have addressed this issue and when the device is offline the call to refresh the token will not be made until the device is online again. This will mean the user is no longer signed out and the username field should be populated with a value provided the app is showing the user as still being signed in.

Currently a beta version of 3.2 is available on the Survey123 Early Adopter Community (EAC) website and this beta version contains the fix if you would like to test it out.

Regards,

Phil.

TI
by
Frequent Contributor

Thanks Phil.  This is good to know.  I need to convince my workplace to upgrade our fleet of iPads before we can upgrade from Survey123 version 2.8.2.  😞  I think I might have convinced them, but time will tell.

MaazaMekuria
Frequent Contributor

I am encountering a problem with the username variable being available in the field app but not in the webform.  Is that normal.  I am using the username variable value to check display fields and ability to post data.  I don't know why the two implementations appear to act differently.   

A piece of the form is posted here,

I can't access the variable 'uname' in the web app.  Users must be logged in to view the form as it is shared to only certain groups. Any ideas?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Maaza,

Instead of using property('username'), I would recommend using a question of type username, which accomplishes the same thing. The property() function has been deprecated from the XLSForm specification and should not be used.

AdminAccount2
Frequent Contributor

Since this is now deprecated, how could I return the results of property('online') to test if a user has connectivity?

Never mind - found the answer here: Prepopulate answers—Survey123 for ArcGIS | Documentation 

0 Kudos
MaazaMekuria
Frequent Contributor

Thank you, James.  The use of the username type resolved the implementation difference between the web form and the field app and loss of username. 

0 Kudos
IsmaelChivite
Esri Notable Contributor

Update. A bunch of options have been added since this question was posted to make life easier.

Check the Device and user properties help topic here: https://doc.arcgis.com/en/survey123/desktop/create-surveys/prepopulateanswers.htm#ESRI_SECTION1_D526...

IsmaelChivite_0-1655688705728.png

 

 

CatherineHall678
Occasional Contributor

Thank you @IsmaelChivite for posting this...way easier!

0 Kudos