Select to view content in your preferred language

PortalUser class 3.xx versus 4.0

3038
10
08-02-2016 03:35 AM
ChrisMahlke
Deactivated User


For 3.xx versions of the JS API, the PortalUser class has the method, getItem(itemId).  This  method enables a user to get the displayName and type and iconUrl of an item.

What is the equivalent method in the 4.0 version?  I see fetchItems(), but that's it.

Ultimately, I am trying to get the displayName and iconUrl property of the item, not just the item's type. 

For example, the item here has a displayName Feature Layer, the type is Feature Collection, and the iconUrl is here.

Screenshot from AGOL showing displayName, type, and icon from iconUrl of item:

screenshot.png

0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Emeritus

Chris,

  The fetchItems method returns an items array of PortalItem

PortalItem | API Reference | ArcGIS API for JavaScript 4.0

Which as a "name", "thumbnailUrl", etc, etc

0 Kudos
by Anonymous User
Not applicable

I'm not seeing the displayName and iconUrl on the returned object.  See the console on the samples below :

http://chrismahlke.github.io/bullrun/prototypes/getItem-3.1.7.html

http://chrismahlke.github.io/bullrun/prototypes/getItem-4.0.html

I do not see where fetchItems() would return the displayName and iconUrl.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Chris,

  So you are saying that the thumbnailUrl​​ and name properties of the PortalItem are not what you are looking for?

0 Kudos
by Anonymous User
Not applicable

Correct.  I am not looking for the title and thumbnailUrl.  I am looking for the displayName and iconUrl.  Looks like they're properties that are not doc'ed.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Chris,

  So when I get my PortalItem I see json like this:

{

  "created": 1447941639000,

  "description": "These are crime committed in Calhoun County Alabama",

  "extent": [

  [

  -86.24999999999855,

  33.55199999999943

  ],

  [

  -85.43199999999855,

  33.97299999999942

  ]

  ],

  "id": "dd84e9a127a640b2af1a7927d77f8c7e",

  "modified": 1470161967000,

  "name": "Crimes",

  "ownerFolder": null,

  "thumbnail": "thumbnail/logo-collections-100x125.png",

  "title": "Calhoun Crimes",

  "type": "Feature Service",

  "typeKeywords": [

  "ArcGIS Server",

  "Data",

  "Feature Access",

  "Feature Service",

  "Service",

  "Singlelayer",

  "Hosted Service"

  ],

  "url": "http://services3.arcgis.com/XItYIm6b3WFtPaRW/arcgis/rest/services/Crimes/FeatureServer"

}

And your saying that the title and thumbnail is not the data you are looking for?

If I use the thumbnail property and add rest of the url like:

http://calhoun.maps.arcgis.com/sharing/rest/content/items/dd84e9a127a640b2af1a7927d77f8c7e/info

to it then I can get the thumbnail that I see when I browse to that feature service in my AGOL content.

0 Kudos
by Anonymous User
Not applicable

Check out these two samples and open the console.

http://chrismahlke.github.io/bullrun/prototypes/getItem-3.1.7.html

http://chrismahlke.github.io/bullrun/prototypes/getItem-4.0.html

You will see 2 properties on the object, displayName and iconUrl in the 3.17 sample but not the 4.0 sample.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Chris,

OK I see what you are saying now. I guess it draws down to JS API 4.0 is stable but not 3.x feature complete.

0 Kudos
KellyHutchins
Esri Frequent Contributor

Hey Chris,

Looks like those two properties where calculated in 3.x.  Looks like both properties were calculated by checking for various typeKeywords. Is there a specific reason why you need to use those properties in an app?

Kelly

0 Kudos
by Anonymous User
Not applicable

Hi Kelly ,  we use them in the Living Atlas and the Living Atlas Contributor application.  I was using the displayName and the iconUrl to mimic what AGOL does (see image below)

screenshot.png

0 Kudos