Select to view content in your preferred language

Arcade vs Portal and GetUser

2881
13
08-22-2023 10:41 AM
Markbe_utco
Regular Contributor

I'm trying to obtain the user from one of the two portals we use.  Sometimes people are logged into both, sometimes only logged into one and sometimes not logged into either of them

Unfortunately if a person is not logged into both portals I get an error message: Failed to query url https://www.WhichEverPortalIsNotLoggedIn .com/ 

Then the script bails out

I cannot figure out how to check to see if getUser can actually obtain something in order to continue the script

var local_portal = Portal('https://gisportal.localcompany.com/portal');
var agol_portal = Portal('https://www.arcgis.com');

var local_user = getUser(local_portal);
var agol_user = getUser(agol_portal);

 

Any suggestions on how to get past this error

Tags (2)
13 Replies
Markbe_utco
Regular Contributor

Understandable and thank you for the time and help.

ToddW_stl
Esri Contributor

were you able to resolve this @Markbe_utco ?

0 Kudos
Markbe_utco
Regular Contributor

No,

0 Kudos
ToddW_stl
Esri Contributor

@Markbe_utco - BLUF: error handling/try-except not supported in Arcade (vote for idea linked below), no way to handle error encountered querying portal users (in Arcade) when not logged in, Python not supported for Attribute Rules, suggest trying editor tracking

---------------------------------------------

If I understand your desired workflow, you want to check "x" number of portals the user may or may not be logged in to in order to capture at least one of their usernames in an attribute field via Attribute Rule in ArcGIS Pro.

I spent a little time testing and trying to come up with a solution, with no luck.  I think a few issues are at play here.

I don't think this is your issue, but noticed the Arcade docs use capital "G" GetUser instead of little "g" getUser in your example(s).

I was able to capture both of my usernames when logged into both portals (ArcGIS Enterprise 11.3 and an ArcGIS Online Organization). 

var agol_portal = Portal('https://www.arcgis.com');
var local_portal = Portal('https://myportal.esri.com/portal');

var local_user = GetUser(local_portal);
var agol_user = GetUser(agol_portal);

var username = local_user.username + ' & ' + agol_user.username;
return username

As you saw and as expected, an error is thrown attempting to GetUser from a portal a user is not logged in to.  I don't see a way around this except making sure your users log in to all necessary portals in Pro to do their work. 

Soo, I thought we could handle the error with a try-except!  Unfortunately, that's not supported in Arcade yet (give it a kudos/vote/whatever here, and I'll do the same: https://community.esri.com/t5/arcgis-pro-ideas/add-error-handling-try-catch-to-arcade-language/idi-p...)

I thought we could use the try-except in Python, but unfortunately (again), Attribute Rules only use Arcade.

My final idea/suggestion (I'll leave leave for you to test and report back on), if possible, would be to enable editor tracking for the data in question:https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/introduction-to-editor-trac... .  Then, if you can't use one of the out of the box username fields, use an Attribute Rule to copy the desired value to your desired field. 

Good luck sir!

0 Kudos