Form Calculate GetUser() Offline

6999
39
04-21-2022 10:56 AM
CraigCheeseman
Regular Contributor

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;

39 Replies
CraigCheeseman
Regular Contributor

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.

0 Kudos
by Anonymous User
Not applicable

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.

CraigCheeseman
Regular Contributor

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.

0 Kudos
CraigCheeseman
Regular Contributor

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.

by Anonymous User
Not applicable

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...

0 Kudos
CraigCheeseman
Regular Contributor

Ok, so is this a bug and is there a workaround if we add editor tracking can we pull from that. I'd like to know as we will need to make changes on several deployments we had planned. 

0 Kudos
by Anonymous User
Not applicable

@CraigCheeseman  Yes there are two bugs that I logged internally:

1. $layer isn't wired up in the mobile apps (this was a late change to the form calculation Arcade Profile that didn't make the last release). This likely will be addressed with our June release - it seems like a quick fix. I don't know if this will work with GetUser($layer) when offline, we'll have to test it.

2. Portal() does not work in a disconnected scenario. This needs additional investigation from our team.

You can use editor tracking, to store the username of the person that created or edited the feature. Those fields are only set when the feature is submitted so they won't help you with any other calculations (since those run before submission).

0 Kudos
ElleniFRogers
Emerging Contributor

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.username
return username

I replaced $layer with FeatureSetByName and this worked in the FieldMaps app and in the Web App. 

Hope this helps!

Elleni

CraigCheeseman
Regular Contributor

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?

0 Kudos