A PortalItem
can be a web map, web scene, layer, file, application or other types of content in an ArcGIS Online or ArcGIS Enterprise portal. With this class, you can access various properties of the portal item, such as item ID, description, URL, access level, owner, type, and more. Additionally, it has certain properties that apply only to specific portal item types, such as an extent property for web maps and scenes and a URL property for layers sourced from a service.
Create a new portal item
Unlike portal users or portal groups, which cannot be created or managed within a ArcGIS Maps SDK for .NET app, portal items can be created, updated, and deleted in such an app. Most of the constructors create an instance that represents an item that already exists in the portal.
One constructor, however, allows you to create a new, empty portal item by instantiating the PortalItem
class and passing the ArcGISPortal
along with information that defines the new item.
You can add content to your new PortalItem
instance by calling PortalItem.UpdateDataAsync()
, which allows you to udpate a portal item with new content defined as text or a file stream.
Finally, you can add the new portal item to the ArcGIS Online or ArcGIS Enterprise portal by calling the AddPortalItemAsync()
on the PortalUser
, which can be retrieved from ArcGISPortal.User
. Pass a PortalItemContentParameters
instance to PortalUser.AddPortalItemAsync()
to define the portal item you are adding.
Access levels
A portal item can have one of several access levels to control the visibility and editability of portal items, ensuring that sensitive information is only accessible to authorized users. The primary PortalAccess
levels are:
- Private: Only the owner can view or edit the item.
- Organization: Only members of the organization can view the item.
- Public: Anyone can view the item.
Shared access level
The fourth access level is Shared and results from a portal item being shared with one or more groups. This access level is not a standalone access level but rather a combination of the item's access level and the groups with which it is shared. It has different effects depending on the primary access level of the item itself.
-
If a private item is shared with a group, it will be accessible to members of that group and the item owner, but remain private to everyone else.
-
If an organization item is shared with a group, it will be accessible to members of that group and the organization, but remain private to everyone else.
-
If a public item is shared with a group, it will be accessible to members of that group and the public. Although a public item is, by definition, accessible to everyone, the advantage to sharing it with a group is that group members will be able to conveniently find and access items relevant to their work, enhancing collaboration.
Sharing a portal item
The PortalItem.Access
property contains the current access level of the portal item. If multiple access levels have been assigned, this property returns only the most permissive level, indicating the widest potential audience that has access to the item.
If you want to change the access level of a portal item, the following steps are recommended:
-
Call
PortalItem.ShareWithAsync()
and pass in the boolean values for theeveryone
andorganization
parameters as shown in the table below.everyone organization result true true Sets access level to public. false true Sets access level to organization. false false Sets access level to private. -
Call
PortalItem.ShareWithGroupsAsync()
and pass in a collection of the IDs of the groups you want to share the item with.
Stop sharing an item
You can also stop all sharing of an item by calling PortalItem.UnshareAsync()
. Alternatively, you can stop sharing an item with specific groups by calling PortalItem.UnshareGroupsAsync()
and passing in the a collection of group IDs.