PortalUser

AMD: require(["esri/portal/PortalUser"], (PortalUser) => { /* code goes here */ });
ESM: import PortalUser from "@arcgis/core/portal/PortalUser.js";
Class: esri/portal/PortalUser
Inheritance: PortalUserAccessor
Since: ArcGIS Maps SDK for JavaScript 4.0

Represents a registered user of the Portal. Personal details of the user, such as email and groups, are returned only to the user or the administrator of the user's organization. View the ArcGIS Portal API REST documentation for the user for more details.

See also

Property Overview

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

Indicates the level of access of the user.

PortalUser

The date the user was created.

PortalUser

The culture information for the user.

PortalUser

The name of the class.

Accessor

A description of the user.

PortalUser

The user's e-mail address.

PortalUser

The user's full name.

PortalUser

The date the user was last modified.

PortalUser

The ID of the organization the user belongs to.

PortalUser

The portal associated with the user.

PortalUser

The user's preferred view for content, either web or GIS.

PortalUser

The user's privileges based on their user type or role in their organization.

PortalUser

The user preferred region, used to set the featured maps on the home page, content in the gallery, and the default extent of new maps in the Viewer.

PortalUser

Defines the user's role in the organization.

PortalUser

The ID of the user's role.

PortalUser

The JSON used to create the property values when the PortalUser is created.

PortalUser

The URL to the thumbnail image for the user.

PortalUser

The user's personal units of measure setting.

PortalUser

The URL for the user's content.

PortalUser

The username of the user.

PortalUser

Property Details

access

Property
access String

Indicates the level of access of the user. If private, the user descriptive information will not be available to others nor will the username be searchable.

Possible Values:"private" |"org" |"public"

created

Property
created Date

The date the user was created.

culture

Property
culture String

The culture information for the user.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.

The name of the class. The declared class name is formatted as esri.folder.className.

description

Property
description String

A description of the user.

email

Property
email String

The user's e-mail address.

fullName

Property
fullName String

The user's full name.

modified

Property
modified Date

The date the user was last modified.

orgId

Property
orgId String

The ID of the organization the user belongs to.

portal

Property
portal Portal

The portal associated with the user.

preferredView

Property
preferredView String

The user's preferred view for content, either web or GIS.

privileges

Property
privileges String[]

The user's privileges based on their user type or role in their organization.

region

Property
region String

The user preferred region, used to set the featured maps on the home page, content in the gallery, and the default extent of new maps in the Viewer.

role

Property
role String

Defines the user's role in the organization. See roleId for more details about when user has a custom role.

Possible Values:"org_admin" |"org_publisher" |"org_user"

roleId

Property
roleId String

The ID of the user's role. Only set if the user is assigned a custom role.

When present, the role will indicate the "base" role of the custom role based on the privileges the custom role contains. For example, if the custom role contains some publisher privileges, the role will be set to org_publisher.

sourceJSON

Property
sourceJSON Object
Since: ArcGIS Maps SDK for JavaScript 4.13 PortalUser since 4.0, sourceJSON added at 4.13.

The JSON used to create the property values when the PortalUser is created. Although most commonly used properties are exposed on the PortalUser class directly, this provides access to all information returned for the portal user. This property is useful if working in an application built using an older version of the API which requires access to a portal's user properties from a more recent version.

thumbnailUrl

Property
thumbnailUrl Stringreadonly

The URL to the thumbnail image for the user.

units

Property
units String

The user's personal units of measure setting.

Possible Values:"english" |"metric"

userContentUrl

Property
userContentUrl Stringreadonly

The URL for the user's content.

username

Property
username String

The username of the user.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor
Promise<PortalItem>

Adds an item to the user's portal content.

PortalUser
Promise

Deletes an item from the user's portal content.

PortalUser

Deletes items from the user's portal content.

PortalUser

Fetches all of the user's folders used to organize portal content.

PortalUser
Promise<PortalGroup[]>

Fetches all the groups that the portal user has permission to access.

PortalUser

Retrieves all the items in either the user's root folder or the specified folder.

PortalUser
Promise<Object[]>

Fetches the tag objects that have been created by the portal user.

PortalUser

Get the URL to the thumbnail image for the user.

PortalUser

Returns true if a named group of handles exist.

Accessor

Executes a query against the user's favorite group to return an array of PortalItem objects that match the input query.

PortalUser

Removes a group of handles owned by the object.

Accessor
Promise

Restores an item from the user's recycle bin to their content.

PortalUser

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

addItem

Method
addItem(params){Promise<PortalItem>}

Adds an item to the user's portal content.

Parameters
Specification
params Object

See the object specifications table below for the parameters that may be passed as properties in this object.

Specification
item PortalItem

The item to add to the user's content.

data String|Object
optional

The component used to stream the data represented by the item to the client.

optional

The portal folder in which to store the item.

Returns
Type Description
Promise<PortalItem> When resolved, returns the PortalItem to be added to the user's content.

deleteItem

Method
deleteItem(item, permanentDelete){Promise}

Deletes an item from the user's portal content.

Parameters
item PortalItem

The portal item to remove.

permanentDelete Boolean
optional
Default Value: false

Since 4.30. When the recycle bin is enabled and the item to be deleted is an item type supported by the recycle bin, this parameter determines if the item should be permanently deleted. If true, the item will be permanently deleted. Otherwise, the item will be moved to the recycle bin. If the recycle bin is disabled, this parameter has no effect. If the item is not supported by the recycle bin, it will be permanently deleted regardless of the value of this parameter.

Returns
Type Description
Promise Resolves when the item has been deleted from the user's content.
Example
// Delete an item from the user's content.
// This will recycle an item if the recycle bin is enabled and item is supported, or
// permanently delete it if the recycle bin is disabled or not supported.
const portalItem = new PortalItem({
  id: "affa021c51944b5694132b2d61fe1057"
});
portal.user.deleteItem(portalItem).then(() => {
  console.log("Item deleted from user's content.");
})
// If the item could not be deleted, an error will be returned.
.catch((error) => {
  console.error("Error deleting item: ", error);
});

deleteItems

Method
deleteItems(items, permanentDelete){Promise<DeleteItemsResult[]>}
Since: ArcGIS Maps SDK for JavaScript 4.8 PortalUser since 4.0, deleteItems added at 4.8.

Deletes items from the user's portal content.

Parameters
items PortalItem[]

The portal items to remove.

permanentDelete Boolean
optional
Default Value: false

Since 4.30. When the recycle bin is enabled and the items to be deleted are item types supported by the recycle bin, this parameter determines if the items should be permanently deleted. If true, the items will be permanently deleted. Otherwise, the items will be moved to the recycle bin. If the recycle bin is disabled, this parameter has no effect. If items are not supported by the recycle bin, they will be permanently deleted regardless of the value of this parameter.

Returns
Type Description
Promise<DeleteItemsResult[]> Resolves to an array of DeleteItemsResult.
Example
// Delete items from the user's content.
// This will permanently delete items even if recycle bin is enabled.
let itemArray = [portalItem1, portalItem2, portalItem3];
portal.user.deleteItems(itemArray, true).then((deleteItemsResults) => {
  deleteItemsResults.forEach((deleteItemsResult) => {
    if (deleteItemsResult.success) {
      console.log(`${deleteItemsResult.item.title} deleted from user's content.`);
    } else {
      console.error(`Error deleting ${deleteItemsResult.item.title}: `, result.error);
    }
  });
});

fetchFolders

Method
fetchFolders(){Promise<PortalFolder[]>}

Fetches all of the user's folders used to organize portal content.

Returns
Type Description
Promise<PortalFolder[]> Resolves to an array of PortalFolder objects representing each of the user's folders in the portal.
Example
// Once portal is loaded, user signed in
portal.load().then(() => {
  portalUser.fetchFolders().then((folders) => {
    folders.forEach((folder) => {
      console.log("User folder", folder.title);
    });
  });
});

fetchGroups

Method
fetchGroups(){Promise<PortalGroup[]>}

Fetches all the groups that the portal user has permission to access.

Returns
Type Description
Promise<PortalGroup[]> Resolves to an array of PortalGroup objects representing each group that the user can access.
Example
// Once portal is loaded, user signed in
portal.load().then(() => {
  // fetch all the groups user can access
  portal.user.fetchGroups().then((groups) => {
    groups.forEach((group) => {
      console.log(`${group.title} group`);
    });
  });
});

fetchItems

Method
fetchItems(params){Promise<FetchItemsResult>}

Retrieves all the items in either the user's root folder or the specified folder.

Parameters
Specification
params Object
optional

See the object specifications table below for the parameters that may be passed as properties in this object.

Specification
folder PortalFolder
optional

The folder to retrieve items from. When folder is not specified, the includeSubfolderItems parameter can be used to include items from subfolders.

inRecycleBin Boolean
optional
Default Value: false

Option to retrieve items from the recycle bin instead.

includeSubfolderItems Boolean
optional
Default Value: false

Option to include items from subfolders along with items in the root folder. This parameter does not apply when the folder parameter is specified.

num Number
optional
Default Value: 10

The maximum number of results to be included in the result set response. The maximum value allowed is 100. The start property combined with the num property can be used to paginate the search results.

sortField String
optional
Default Value: created

A comma-delimited list of fields to sort by. Allowed values are created, modified, size, and type.

sortOrder String
optional
Default Value: asc

The order in which to sort the results. Allowed values are asc for ascending order and desc for descending order.

start Number
optional
Default Value: 1

The index of the first entry in the result set response. The index is 1-based.

Returns
Type Description
Promise<FetchItemsResult> Resolves to a FetchItemsResult.
Examples
// Retrieves items from the user's root folder.
portal.user.fetchItems().then((fetchItemsResult) => {
   console.log("Next start index: ", fetchItemsResult.nextStart);
   fetchItemsResult.items.forEach((item) => {
     console.log("Portal item title:", item.title);
   });
});
// Retrieves items from the recycle bin which will include items from the user's root and subfolders.
portal.user.fetchItems( { inRecyclebin: true, includeSubfolderItems: true }).then((fetchItemsResult) => {
  console.log("next start index: ", fetchItemsResult.nextStart);
  fetchItemsResult.items.forEach((item) => {
    console.log("Portal item title:", item.title);
  });
});

fetchTags

Method
fetchTags(){Promise<Object[]>}
Since: ArcGIS Maps SDK for JavaScript 4.14 PortalUser since 4.0, fetchTags added at 4.14.

Fetches the tag objects that have been created by the portal user.

Returns
Type Description
Promise<Object[]> Resolves to an array of objects with the following properties:
Property Type Description
tag string The name of the tag.
count number The number of times the tag was used.

getThumbnailUrl

Method
getThumbnailUrl(width){String}
Since: ArcGIS Maps SDK for JavaScript 4.4 PortalUser since 4.0, getThumbnailUrl added at 4.4.

Get the URL to the thumbnail image for the user.

Available width sizes: 150, 300 and 600.

Parameter
width Number
optional

The desired image width.

Returns
Type Description
String The URL to the thumbnail image.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

queryFavorites

Method
queryFavorites(queryParams){Promise<PortalQueryResult>}

Executes a query against the user's favorite group to return an array of PortalItem objects that match the input query.

Parameter
queryParams PortalQueryParams
optional

The input query parameters defined in PortalQueryParams. This object may be autocast.

Returns
Type Description
Promise<PortalQueryResult> When resolved, resolves to an instance of PortalQueryResult which contains a results array of PortalItem objects representing all the items that match the input query.

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

restoreItem

Method
restoreItem(item, folder){Promise}
Since: ArcGIS Maps SDK for JavaScript 4.30 PortalUser since 4.0, restoreItem added at 4.30.

Restores an item from the user's recycle bin to their content. This method only applies if the recycle bin is enabled on the organization.

Parameters
item PortalItem

The portal item to restore.

optional

The folder to restore the item to. If not specified, the item will be restored to the root folder. If an invalid folder is specified, an error will be returned and the item will not be restored.

Returns
Type Description
Promise Resolves when the item has been restored to the user's content.
Examples
// Restore a recycled item to the root folder.
const portalItem = new PortalItem({
  id: "affa021c51944b5694132b2d61fe1057"
});
portal.user.restoreItem(portalItem).then(() => {
   console.log("Item restored to root folder.")
});
// Restore a recycled item to a specified folder.
const portalItem = new PortalItem({
  id: "affa021c51944b5694132b2d61fe1057"
});
// This can be a PortalFolder object or a folder ID string.
const portalFolder = "6bbff8b7f2b54c628603135b72f9cb55";
portal.user.restoreItem(portalItem, portalFolder).then(() => {
   console.log("Item restored to folder with ID: '6bbff8b7f2b54c628603135b72f9cb55'.")
});

Type Definitions

DeleteItemsResult

Type Definition
DeleteItemsResult

The result of the deleteItems() method containing the item, if deletion is successful, and error, if any.

Properties
item PortalItem

An item from the items parameter of deleteItems().

success Boolean

Indicates whether the item was successfully deleted.

error Error
optional

The error if the item was not deleted.

FetchItemsResult

Type Definition
FetchItemsResult

The result of the fetchItems() method containing an array of the fetched portal items, the next entry index, and the total number of results.

Properties
items PortalItem[]

An array containing user's portal items.

nextStart Number

The next entry index if the current result set doesn't contain all results.

total Number

The total number of results.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.