Select to view content in your preferred language

getuser() issues with registered enterprise service in AGOL while disconnected

190
3
a week ago
PaulPetersen1
Frequent Contributor

I came upon a weird issue yesterday. In one of our projects, we registered an Enterprise feature service to AGOL, and we use an Arcade field calculation to populate an "Inspector" attribute using GetUser($layer).username. As noted in previous threads, the .fullname property does not work offline, but the .username property does work offline.

However...we have found the following combination creates an unexpected result:

  • If using GetUser($layer).username with a registered Enterprise feature service in AGOL
  • ...with an offline map
  • ...and in Airplane Mode (or cellular turned off)
  • ...returns the Portal user name of the user who registered the Enterprise service to AGOL, instead of the currently logged-in AGOL user

Everything works fine if there is any sort of connectivity. In other words, works fine with an offline map as long as you have a pulse on your cellular. Also works fine with hosted layers, of course.

I did find a workaround:

  • Create a new, empty hosted layer in AGOL
  • Enable sync, add to the Field Map, turn off editing for the layer in Field Maps
  • In Field Maps config, direct the getuser() function toward this AGOL hosted layer rather than the current registered Enterprise layer. ex: 
var user = GetUser(FeatureSetByName($map,"Layer_Name"), true)
var username = user.username
 
Then everything works fine, just need to add a "fake" hosted layer into the map to force Field Maps to do the right thing.
 

Surely this is a bug? Returning the login info of the app seems like a pretty basic function, not sure why it's tied to the data layer and not the app itself. Am I missing something? Is there a more elegant way to do this that doesn't involve adding a fake layer?

3 Replies
PaulPetersen1
Frequent Contributor

Thanks Doug. I've seen those posts. The main thing that makes my case unique is registering an Enterprise service with AGOL. So far I haven't seen any workarounds besides the one I just came up with.

RhettZufelt
MVP Notable Contributor

In one case I overcame this by enabling editor tracking which will capture the logged in username.

Then, since it is registered Enterprise service, I have a trigger in the database that calculates the user info to the appropriate table/fields(s).  Couldn't just use editor tracking as I needed the username updated in a related tracking table.

Have not tested in a completely offline/disconnected environment.

R_

0 Kudos