Has anyone had success calculating the username when offline? Documentation says I should be able to use the layer. Works testing but does not work in app.
var u = getUser($layer);var fullName = u.fullName;return fullName;
Okay, I've confirmed that the offline area doesn't appear to download my hosted table, and this is why the calculation fails. I tried using a point FS with records added to attribute table and no actual point geometry (appended my table to the host point feature layer). This also doesn't work; I believe the offline map is not downloading the records needed for filter() function.
The only way I can see that this seems to work is if I have a feature within the download area that gets downloaded and can be used as lookup record.
So my workaroud will be to try and create a polyline or polygon FL that contains a bunch identical features which span across the state of Washington and will be captured by any one of the offline areas our surveyors might use. Feature attributes will contain my lookup data. This is insanely messy...
If anybody has a better solution, I'd love to hear it. or if @JeffShaner and team can help with this bug (ENH-000157471), I think a lot of people could benefit.
Thanks!
I tried using a table for this. Works in online map, but fails in offline map, even when not fully disconnected... Does Field Maps not support hosted tables in offline maps? I tried using a point feature layer as well, but any features that fall outside of offline area aren't downloaded. Maybe this would work if I added records to the table without geometry?
Curious how you made this work 😅
I had considered the same thing, but it seems just so complicated for such a single record 😅
Instead, we decided make a join with a table that contains all the full names when we extract the fielddata from the Field Maps. It's a shame that we have to bother with it, but we can't risk locking the field app when we're in the field.
Christian, it's a bit annoying, but as a workaround, I store some default data (including full names) in a separate layer, use the username to filter that table down to a single record, and then pull the values into the form.
var context = $editcontext.edittype var settings = FeatureSetByName($map, 'layer', ['*'], false) var currentuser = GetUser(settings).username var filtered_settings = Filter(settings, 'AGOL_User = @currentuser') if (context == 'INSERT' && Count(filtered_settings) > 0){ return First(filtered_settings).FieldName }else { return $feature.FieldName }
Wow thank you! Not sure exactly why this works, but this is great. Just finished coding up some forms that pull a bunch of default values from an initial 'settings' FeatureSet filtered by username, and found that GetUser() by itself did not work in Field Maps. Your solution works for me, online and offline.
Are there any updates on this issue? We need to be able to log the full name of our geologists and not just their username when they are collecting data in the field in Greenland. The following code works fine when online, but not when taking the device offline:
GetUser(FeatureSetByName($map, 'Locality')).fullname
Yes it works or its been working and biologists are collecting data in Alaska working on skiffs/remotely...... Full name would not work because when offline you only have access to the Field Maps username as they are signed in. I think I tried fullName and that did work only online. That is my understanding/experience.
Interesting! @kmsmikrud can you confirm this works when fully disconnected? ie., turn off wifi and cell data on the device. Your Arcade code looks similar to mine, except that I'm pulling fullName rather than username, and it will work for me in a downloaded offline map only when my device has an internet connection.
Hi @BrantCarman
We have been using GetUser() offline for the last month and it is grabbing usernames in Field Maps successfully 🙂 Below populates the sampler name field based on username.
var user = GetUser(FeatureSetByName($map, 'Herring Samples:')).username var sampler = Split(user,'.') var user1 = Proper(sampler[0]) var user2 = Split(sampler[1],'_') var fid = Text(user1 + " " + Proper(user2[0])) return fid
@Anonymous User you seem to be the person with the answers! Any update on this?
I came up with a way to generate a unique ID for a feature with Arcade in Field Maps, but it utilizes GetUser()... Really a bummer that this doesn't work in a disconnected environment. Here's the post on creating that unique ID if anybody can benefit: https://community.esri.com/t5/arcgis-collector-questions/field-maps-arcade-expression-calculation-only/td-p/1271471
Has this fix been pushed to Enterprise 11?
Hi! @Anonymous User ,
Any updates on the GetUser() working offline in Field Maps?
Thanks,Kathy
Just wanted to mention that we were using this on a hidden field, so when the user hits the Submit button, they receive an error message:
Unable to Submit.
1 Hidden Attribute Failed.
@Anonymous User do you know if there are plans to add this functionality in? As of now the GetUser() is still not working in offline mode.
As far as I know, Portal() and GetUser() are the only functions that do not work offline now. We fixed several issues with feature sets and relationships with the 22.3 release so those should work offline now in all cases.
Thanks @Anonymous User.
Can you confirm whether any other Arcade expressions will work/fail when the device is fully offline? Or is GetUser a special case?
I'm using GetUser(FeatureSetByName($map,"NameOfLayerInForm")).fullname and it's not working even when I download a map for offline use (i.e. still connected to the internet, but offline map downloaded).
This scenario should be fixed with our release scheduled for next week.
For the second scenario, when the device is offline, the expression will fail. This is still under investigation and won't make this release.
@Anonymous User Is there any update on this?
Using AGOL and Field Maps v 22.2.1 on Android.
Ok. Thanks for confirming. I used your code with obviously updating "Feature" to the correct value from my map. I will double check that I didn't do anything wrong but it did return the correct value when testing in the Web Editor. Just to confirm are you using Enterprise or AGO?
I also see it work offline and disconnected. Nice idea @ElleniFRogers !
GetUser(FeatureSetByName($map, 'GetUserTest')).username
I also just tested an internal build that addresses the $layer issue, and that also works fully disconnected.
Hi @CraigCheeseman
Hmm, that is strange. I can confirm I turned my phone to airplane mode, switched off wifi and cellular and it still works on the downloaded map. When I used $layer it didn't work, but by switching to the FeatureSetByName function it did. Can you paste your code with the FeatureSetByName function?
Elleni
Hi Elleni,
Thanks for the info. I am not having success when fully disconnected. It works in a downloaded map but when I turn off Wifi and Cell I see an error. Could you verify you are fully disconnected?
Hi @CraigCheeseman @Anonymous User ,
EDIT: I just tested with an offline area and it works 🙂
Yet to test offline, but I was also struggling to get this to work in the FieldMaps app. Worked fine in the WebApp but not in the mobile app once editing. Having come across your post, I decided to test the following code:
var user = GetUser(FeatureSetByName($map,"FEATURE"), true)var username = user.usernamereturn username
I replaced $layer with FeatureSetByName and this worked in the FieldMaps app and in the Web App.
Hope this helps!
Oh I see, I just created the offline area but was still "connected". I see the original issue now. Seems like there's two issues here...
Hi @Anonymous User it is as I thought. There is a difference between offline and fully disconnected. Your code does work offline but it assumes you still have some sort of connection to access the portal address. If you have no cell or wifi it does not work.
Thanks. I was using it via the portal before but that also didn't work with my code but did work online. I will try this and report back.
Can you try:
GetUser(Portal('https://arcgis.com')).fullName
This works for me online and offline. I can reproduce the issue when using $layer though, we'll have to look into that more.
A bump for this. @Anonymous User this was shown at the Dev summit along with calculating hidden fields. Any help on either would be great. Thanks.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.