Skip To Content ArcGIS for Developers Sign In Dashboard

PortalItem QML Type

An item in a portal. More...

Import Statement: import Esri.ArcGISRuntime 100.9
Since: Esri.ArcGISRuntime 100.0
Inherits:

ArcGISItem

Properties

Signals

Methods

Detailed Description

Contains information about an item of content within the portal. Each item has a unique identifier and a well-known URL that is independent of the user owning the item.

A new item can be created using PortalUser.addPortalItemWithJson or PortalUser.addPortalItemWithUrl; or an existing item can be loaded from online portal using PortalItem.load.

An item may also have associated binary or textual data which can be downloaded separately.

Create a new portal item

To add a new item to a portal, create the PortalItem object passing the portal as a parameter to the constructor, then call PortalUser::addPortalItemWithJson or PortalUser::addPortalItemWithUrl. The portal user must have been created with credentials that provide sufficient privileges to add items to the portal.

Before adding an item to the portal, the title and type must be set. If itemId is set, this will be ignored and a new unique ID will be provided when the item is added to the portal and loaded.

PortalItem {
    id: portalItemWithoutId
    portal: portal
    title: "My Item"
    type: Enums.PortalItemTypeWebMap
    onErrorChanged: console.log("Error in portal item: " + error.message + "(" + error.additionalMessage + ")");
    onItemIdChanged: console.log("Item receive itemId: " + itemId);
}

function addPortalItem(json) {
    portal.portalUser.addPortalItemWithJson(portalItemWithoutId, json);
}

Load existing portal item

To load an existing item from portal, create a PortalItem object with a valid itemId, set using one of:

After this information is set, call PortalItem::load.

The portal item ID can be used along with a portal URL to quickly instantiate a new portal item object. The ID can be determined from the URL of the item details web page or the map viewer URL (for maps only) in your portal. The item details page has the following format: http://www.arcgis.com/home/item.html?id=[itemId]. The web map viewer has the following format: http://www.arcgis.com/home/webmap/viewer.html?webmap=[itemId]. In both cases the [itemId] can be used as the ID to instantiate a portal item.

PortalItem {
    id: portalItemWithId
    portal: portal
    itemId: id
    onErrorChanged: {
        console.log("Error in portal item: " + error.message + "(" + error.additionalMessage + ")");
    }
    onLoadStatusChanged: {
        if (loadStatus === Enums.LoadStatusLoaded)
            console.log("Item title: " + title);
    }
}

function loadPortalItem() {
    portalItemWithId.load();
}

Retrieve an existing portal item

Alternatively, you can search for and load existing items in the portal using Portal::findItems or PortalUser::items. If you know the specific ID of the item you wish to retrieve, you can construct the portalItem by passing both the portal and the ID to it's constructor and calling PortalItem::load to retrieve the details.

This QML type supports the following default properties. A default property may be declared inside another declared object without being assigned explicitly to a property.

TypeDefault Property
Portalportal

See also JsonSerializable, Loadable, and Portal.

Property Documentation

access : Enums.PortalAccess

Returns the level of access to this item (read-only).

See also Enums.PortalAccess.


addCommentStatus : Enums.TaskStatus

Returns the status of the addComment method (read-only).

See also Enums.TaskStatus.


addRatingStatus : Enums.TaskStatus

Returns the status of the addRating method (read-only).

See also Enums.TaskStatus.


adminGroups : PortalGroupListModel

Returns a list of groups that the item is in and for which the current portal user is an administrator (read-only).

To access these groups, call fetchGroups, and wait for the fetchGroupsStatusChanged signal to emit with a status of Enums.TaskStatusCompleted.


averageRating : real

Returns the average rating of this item (read-only).

Uses a weighted average called "Bayesian average."


commentCount : int

The number of comments that the PortalItem has (read-only).


The list of comments associated with this PortalItem.

To access these comments, call fetchComments, and wait for the fetchCommentsStatusChanged signal to emit with a status of Enums.TaskStatusCompleted.


commentsEnabled : bool

Returns whether comments are allowed on the item (read-only).


culture : string

Returns the item's locale information (language and country) (read-only).


failedToShareGroupIds : list<string>

Returns the list of groups the item could not be shared with.

This property was introduced in Esri.ArcGISRuntime 100.1.


failedToUnshareGroupIds : list<string>

Returns the list of groups the item could not be unshared with.

This property was introduced in Esri.ArcGISRuntime 100.1.


fetchCommentsStatus : Enums.TaskStatus

Returns the status of the fetchComments method (read-only).

See also Enums.TaskStatus.


fetchDataProgress : NetworkRequestProgress

Returns progress information for the fetch data request.


fetchGroupsStatus : Enums.TaskStatus

Returns the status of the fetchGroups method (read-only).

See also Enums.TaskStatus.


folderId : string

Returns the ID of the folder containing this item (read-only).


itemId : string

The ID of the portal item.

Set this property if you wish to fetch a particular item from a portal. Call load on the object to fetch the metadata for this item. Note that most of the properties will return null, 0 or an empty string until the load operation is complete (see loadStatus).

The ID can also be determined from the URL of the item details web page or the map viewer URL (for maps only) in your portal. The item details page has the following format: http://www.arcgis.com/home/item.html?id=[itemId]. The web map viewer has the following format: http://www.arcgis.com/home/webmap/viewer.html?webmap=[itemId]. In both cases the [itemId] can be used to set the itemId property.

This property cannot be changed after the object is loaded.


json : jsobject

The JSON representation of the PortalItem


loadError : Error

Returns the Error for the item (read-only).

See also Loadable.


loadStatus : Enums.LoadStatus

Returns the load status of the item (read-only).

See also Enums.LoadStatus.


memberGroups : PortalGroupListModel

Returns a list of groups that the item is in and for which the current portal user is a member (read-only).

To access these comments, call fetchGroups, and wait for the fetchGroupsStatusChanged signal to emit with a status of Enums.TaskStatusCompleted.


otherGroups : PortalGroupListModel

Returns a list of groups that the item is in that are public or shared to the user's organization, but that the current user is not a member (read-only).

To access these comments, call fetchGroups, and wait for the fetchGroupsStatusChanged signal to emit with a status of Enums.TaskStatusCompleted.


owner : string

Returns the username of the user who owns this item (read-only).


[default] portal : Portal

The portal that this item is associated with.

This property cannot be changed after the object is loaded.


ratingCount : int

Returns the number of ratings for this item (read-only).


serviceUrl : url

Returns the service URL for this item (read-only).


shareWithGroupsStatus : Enums.TaskStatus

Returns the status of the shareWithGroups method.

See also Enums.TaskStatus.


shareWithStatus : Enums.TaskStatus

Returns the status of the shareWith method (read-only).

See also Enums.TaskStatus.


size : string

Returns the size of the item in bytes (read-only).

Note: The underlying Runtime property is represented as a 64-bit integer type. See Accessing 64-bit integer properties from QML.

See also sizeAsInt.


sizeAsInt : int

The same as size but represented as an integer type (read-only).

Note: The underlying Runtime property is represented as a 64-bit integer type. See Accessing 64-bit integer properties from QML.

This property was introduced in Esri.ArcGISRuntime 100.3.


type : Enums.PortalItemType

The item's type.

Note: Setting this property is only allowed during instantiation starting at the 100.6 release. This is because the Portal Rest API does not allow changing the type of an existing PortalItem.

See also Enums.PortalItemType.


typeName : string

Returns the name of the type of this item (read-only).


unknownJson : jsobject

Returns the unknown JSON from the source JSON.

See also JsonSerializable.


unshareGroupsStatus : Enums.TaskStatus

Returns the status of the unshareGroups method (read-only).

See also Enums.TaskStatus.


unshareStatus : Enums.TaskStatus

Returns the status of the unshare method (read-only).

See also Enums.TaskStatus.


unsupportedJson : jsobject

Returns the unsupported data from the source JSON.

See also JsonSerializable.


updateDataStatus : Enums.TaskStatus

Returns the status of the updateDataWithJson or updateDataWithUrl method (read-only).

This property was introduced in Esri.ArcGISRuntime 100.1.

See also Enums.TaskStatus.


url : url

Returns the url of the portal item.

The supported URL formats are:

  • The URL of the portal item (with or without the query parameter f=json). Example: http://www.arcgis.com/sharing/rest/content/items/12345678901234567890123456789012?f=json
  • The URL of the portal item data. Example: http://www.arcgis.com/sharing/rest/content/items/12345678901234567890123456789012/data
  • The URL of an ArcGIS.com item. Example: http://www.arcgis.com/home/item.html?id=12345678901234567890123456789012
  • The URL of an ArcGIS.com web map viewer. Example: http://www.arcgis.com/home/webmap/viewer.html?webmap=12345678901234567890123456789012

This property cannot be changed after the object is loaded.


viewCount : int

The number of views of this PortalItem (read-only).


Signal Documentation

accessAndUseConstraintsHtmlChanged()

Emitted when the accessAndUseConstraintsHtml property changes.

Note: The corresponding handler is onAccessAndUseConstraintsHtmlChanged.


accessChanged()

Emitted when the access property changes.

Note: The corresponding handler is onAccessChanged.


addCommentStatusChanged()

Emitted when the addCommentStatus property changes.

Note: The corresponding handler is onAddCommentStatusChanged.


addRatingStatusChanged()

Emitted when the addRatingStatus property changes.

Note: The corresponding handler is onAddRatingStatusChanged.


averageRatingChanged()

Emitted when the averageRating property changes.

Note: The corresponding handler is onAverageRatingChanged.


commentCountChanged()

Emitted when the commentCount property changes.

Note: The corresponding handler is onCommentCountChanged.


commentsEnabledChanged()

Emitted when the commentsEnabled property changes.

Note: The corresponding handler is onCommentsEnabledChanged.


cultureChanged()

Emitted when the culture property changes.

Note: The corresponding handler is onCultureChanged.


failedToShareGroupIdsChanged()

Emitted when the failedToShareGroupIds property changes.

Note: The corresponding handler is onFailedToShareGroupIdsChanged.

This signal was introduced in Esri.ArcGISRuntime 100.1.


failedToUnshareGroupIdsChanged()

Emitted when the failedToUnshareGroupIds property changes.

Note: The corresponding handler is onFailedToUnshareGroupIdsChanged.

This signal was introduced in Esri.ArcGISRuntime 100.1.


fetchCommentsStatusChanged()

Emitted when the fetchCommentsStatus property changes.

Note: The corresponding handler is onFetchCommentsStatusChanged.


fetchDataProgressChanged()

Emitted when the fetchDataProgress property changes.

Note: The corresponding handler is onFetchDataProgressChanged.


fetchGroupsStatusChanged()

Emitted when the fetchGroupsStatus property changes.

Note: The corresponding handler is onFetchGroupsStatusChanged.


folderIdChanged()

Emitted when the folderId property changes.

Note: The corresponding handler is onFolderIdChanged.


jsonChanged()

Emitted when the json property changes.

Note: The corresponding handler is onJsonChanged.


loadErrorChanged()

Emitted when the loadError property changes.

Note: The corresponding handler is onLoadErrorChanged.


loadStatusChanged()

Emitted when the loadStatus property changes.

Note: The corresponding handler is onLoadStatusChanged.


ownerChanged()

Emitted when the owner property changes.

Note: The corresponding handler is onOwnerChanged.


portalChanged()

Emitted when portal property is changed.

Note: The corresponding handler is onPortalChanged.


ratingCountChanged()

Emitted when the ratingCount property changes.

Note: The corresponding handler is onRatingCountChanged.


serviceUrlChanged()

Emitted when the serviceUrl property changes.

Note: The corresponding handler is onServiceUrlChanged.


shareWithGroupsStatusChanged()

Emitted when the shareWithGroupsStatus property changes.

Note: The corresponding handler is onShareWithGroupsStatusChanged.


shareWithStatusChanged()

Emitted when the shareWithStatus property changes.

Note: The corresponding handler is onShareWithStatusChanged.


sizeAsIntChanged()

Emitted when the sizeAsInt property changes.

Note: The corresponding handler is onSizeAsIntChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


sizeChanged()

Emitted when the size property changes.

Note: The corresponding handler is onSizeChanged.


typeChanged()

Emitted when the type property changes.

Note: The corresponding handler is onTypeChanged.


typeNameChanged()

Emitted when the typeName property changes.

Note: The corresponding handler is onTypeNameChanged.


unshareGroupsStatusChanged()

Emitted when the unshareGroupsStatus property changes.

Note: The corresponding handler is onUnshareGroupsStatusChanged.


unshareStatusChanged()

Emitted when the unshareStatus property changes.

Note: The corresponding handler is onUnshareStatusChanged.


updateDataStatusChanged()

Emitted when the updateDataStatus property changes.

Note: The corresponding handler is onUpdateDataStatusChanged.

This signal was introduced in Esri.ArcGISRuntime 100.1.


urlChanged()

Emitted when url property is changed.

Note: The corresponding handler is onUrlChanged.


viewCountChanged()

Emitted when the viewCount property changes.

Note: The corresponding handler is onViewCountChanged.


Method Documentation

void addComment(comment)

Adds a comment to the PortalItem.

The addCommentStatus property shows whether the operation was successful.


void addRating(rating)

Adds a rating to the PortalItem.

The addRatingStatus property shows whether the operation was successful.

rating must be a floating point number between 1.0 and 5.0.


void cancelLoad()

See Loadable.


void fetchComments()

Starts an asynchronous task to fetch comments.

Example: Add a comment and fetch the comments model for an item:

Connections {
    target: portalItem
    onAddCommentStatusChanged: {
        if (portalItem.addCommentsStatus !== Enums.TaskStatusCompleted)
            return;

        console.log("comment added");
    }

    onFetchCommentsStatusChanged: {
        if (portalItem.fetchCommentsStatus !== Enums.TaskStatusCompleted)
            return;

        console.log("total comments = " + portalItem.comments.count);
    }
}

The fetchCommentsStatusChanged signal will emit once complete.


void fetchGroups()

Starts an asynchronous task to fetch the groups that this item belongs to.

Only those groups that are visible to the current portal user will be returned. The fetchGroupsStatusChanged signal will emit once complete and the fetchGroupsStatus property will show whether the operation was successful.


void load()

See Loadable.


void retryLoad()

See Loadable.


void shareWith(everyone, bool organization)

Shares a PortalItem with everyone and/or the organization the item belongs to.


void shareWithGroups(groupIds)

Shares a PortalItem with the specified list of groupIds.


void unshare()

Unshares the PortalItem with everyone.


void unshareGroups(groupIds)

Unshares a PortalItem with the specified list of groupIds.


void updateDataWithJson(json)

Starts an asynchronous task to update the remote PortalItem with the provided json.

The updateDataStatus property shows the status of the operation.

This method was introduced in Esri.ArcGISRuntime 100.1.


void updateDataWithUrl(fromUrl, string fileName)

Starts an asynchronous task to update the remote PortalItem from a local or online URL.

The portalItem will be updated using the following arguments:

  • fromUrl - The local or online URL from which the portalItem will be populated. For local files, this should be of the form "qrc:/example.csv" or "file://"; for online resources this should be of the form "https://...".
  • fileName - (optional). The name of the file which will be associated with the PortalItem (including extension). If a file name is not supplied, the portal item will have no file associated with it for future downloads.

    Note: A file name is only relevant for certain item types such as Enums.PortalItemType Enums.PortalItemTypeImage.

The updateDataStatus property shows the status of the operation.

This method was introduced in Esri.ArcGISRuntime 100.1.

See also Items and item types.



Feedback on this topic?