Select to view content in your preferred language

PortalUser class 3.xx versus 4.0

3045
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
JohnGrayson
Esri Regular Contributor
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>Load Portal Item</title>
    <style>
      html,
      body {
        font-family: sans-serif;
        padding: 0;
        margin: 0 !important;
        height: 100%;
        width: 100%;
      }
      #item-node {
        width: 100%;
        height: 100%
      }
    </style>
    <script src="https://js.arcgis.com/4.0/"></script>
    <script>
      require([
        "esri/portal/PortalItem",
        "dojo/dom",
        "dojo/json",
        "dojo/domReady!"
      ], function(PortalItem, dom, json) {
        var portalItem = new PortalItem({
          id: "6ada2b1c6a0a43e0861d72938dcdcb92"
        });
        portalItem.load().then(function(loadedItem) {
          dom.byId("item-node").innerHTML = json.stringify(loadedItem, null, "  ");
        },function(error){
          dom.byId("item-node").innerHTML = json.stringify(error, null, "  ");
        });
      });
    </script>
  </head>
  <body>
    <pre id="item-node"></pre>
  </body>
</html>