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;
A bump for this. @AaronPulver this was shown at the Dev summit along with calculating hidden fields. Any help on either would be great. Thanks.
Can you try:
This works for me online and offline. I can reproduce the issue when using $layer though, we'll have to look into that more.
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.
Hi @AaronPulver 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.
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...
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.
@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).
Hi @CraigCheeseman @AaronPulver ,
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
I replaced $layer with FeatureSetByName and this worked in the FieldMaps app and in the Web App.
Hope this helps!
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?