Portal functions

A set of functions for working with information from a portal.


FeatureSetByPortalItem

FeatureSetByPortalItem(portalObject, itemId, layerId?, fields?, includeGeometry?) -> FeatureSet

Since version 1.8

Function bundle: Portal Access

Profiles: Dashboard Data | Field Calculation | Form Calculation | Popups | Tasks

Creates a FeatureSet from a Feature Layer in a portal item from a given Portal. Limiting the number of fields in the FeatureSet and excluding the geometry can improve the performance of the script.

Parameters

  • portalObject: Portal - The Portal from which to query features from a given portal item ID.
  • itemId: Text - The GUID of the portal item referencing a feature layer or feature service. Please note that this value must be a text literal.
  • layerId (Optional): Number - The ID of the layer in the feature service. This layer must be created from a feature service; feature collections are not supported.
  • fields (Optional): Array<Text> - The fields to include in the FeatureSet. By default, all fields are included. To request all fields in the layer, set this value to ['*']. Limiting the number of fields improves the performance of the script.
  • includeGeometry (Optional): Boolean - Indicates whether to include the geometry in the features. For performance reasons, you should only request the geometry if necessary, such as for use in geometry functions.

Return value: FeatureSet

Example

Returns the number of features in the layer from a different portal than the feature in the map.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
var features = FeatureSetByPortalItem(
  Portal('https://www.arcgis.com'),
  '7b1fb95ab77f40bf8aa09c8b59045449',
  0,
  ['Name', 'Count'],
  false
);
Count(features);

GetUser

This function has 2 signatures:

GetUser(portalObject?, username?) -> Dictionary

Since version 1.12

Function bundle: Data Access

Profiles: Attribute Rules | Dashboard Data | Popups | Field Calculation | Form Calculation | Tasks

Returns the current user from the workspace. For data from a service, either the Portal user or Server user is returned. For data from a database connection, the database user is returned. When no user is associated with the workspace, such as a file geodatabase, a null value will be returned.

Parameters

  • portalObject (Optional): Portal - A Portal from which to return the current user. If no portal is specified, then user information from the active portal is returned.
  • username (Optional): Text - The username of the user you want to return. Only limited information will be returned based on your permissions when making the request.

Return value: Dictionary
Returns a dictionary described by the properties below. In an offline workflow, only the username will be returned.

  • email: Text - The email address associated with the user's account.
  • fullName: Text - The user's first and last name.
  • groups: Array<Text> - An array of groups that the user belongs to.
  • id: Text - The user id of the returned user.
  • privileges: Array<Text> - An array of privileges that the user has within their organization (e.g. edit, view, etc).
  • role: Text - The role that the user plays within their organization (e.g. Administrator, Publisher, User, Viewer, or Custom).
  • username: Text - The username of the returned user.

Examples

Returns username for the currently logged in user of the active portal. If no user is associated with the portal, this will return null.

Use dark colors for code blocksCopy
1
2
3
4
var userInfo = GetUser();
if(HasValue(userInfo, "username")){
  return userInfo.username;
}

Returns the dictionary for the user currently logged in based on the workspace connection from the given portal.

Use dark colors for code blocksCopy
1
GetUser(Portal('https://www.arcgis.com'))

GetUser(portalObject?, extensions?) -> Dictionary

Since version 1.12

Function bundle: Data Access

Profiles: Attribute Rules | Popups | Field Calculation | Form Calculation | Tasks

Returns the current user from the workspace. For data from a service, either the Portal user or Server user is returned. For data from a database connection, the database user is returned. When no user is associated with the workspace, such as a file geodatabase, a null value will be returned.

Parameters

  • portalObject (Optional): Portal - A Portal from which to return the current user. If no portal is specified, then user information from the active portal is returned.
  • extensions (Optional): Boolean - Determines if the userLicenseTypeExtensions will be returned in the dictionary.

Return value: Dictionary
Returns a dictionary described by the properties below. In an offline workflow, only the username will be returned.

  • id: Text - The user id of the returned user.
  • username: Text - The username of the returned user.
  • fullName: Text - The user's first and last name.
  • email: Text - The email address associated with the user's account.
  • groups: Array<Text> - An array of groups that the user belongs to.
  • role: Text - The role that the user plays within their organization (e.g. Administrator, Publisher, User, Viewer, or Custom).
  • privileges: Array<Text> - An array of privileges that the user has within their organization (e.g. edit, view, etc).
  • userLicenseTypeExtensions: Array<Text> - An array of the license type extensions associated with the user's account (e.g. "Utility Network", "Parcel Fabric", etc). The extensions parameter must be set to true in order for this to be returned.

Examples

Returns user information for the active portal. If no user is associated with the portal, this will return null.

Use dark colors for code blocksCopy
1
GetUser()

Returns information about the user currently logged in based on the portal with user extensions.

Use dark colors for code blocksCopy
1
GetUser(Portal('https://www.arcgis.com'), true)

Portal

Portal(url) -> Portal

Since version 1.8

Function bundle: Data Access

Profiles: Field Calculation | Form Calculation | Popups | Tasks

Creates a reference to an ArcGIS Portal.

Parameter

  • url: Text - The url of the portal.

Return value: Portal

Examples

Query features from a portal item in ArcGIS Online

Use dark colors for code blocksCopy
1
2
var arcgisPortal = Portal('https://www.arcgis.com');
var features = FeatureSetByPortalItem(arcgisPortal, '7b1fb95ab77f40bf8aa09c8b59045449', 0, ['Name', 'Count'], false);

Enterprise Portal

Use dark colors for code blocksCopy
1
Portal('https://www.example.com/arcgis')

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