A set of functions for working with information from a portal.
FeatureSetByPortalItem
FeatureSetByPortalItem(portalObject, itemId, layerId?, fields?, includeGeometry?) -> FeatureSet
Function bundle: Portal Access
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.
var features = FeatureSetByPortalItem(
Portal('https://www.arcgis.com'),
'7b1fb95ab77f40bf8aa09c8b59045449',
0,
['Name', 'Count'],
false
);
Count(features);GetGroups
GetGroups(portalObject?, options?) -> Array<Dictionary>
Function bundle: Data Access
Returns groups, or a collection of items, in a portal. If no portal is specified, the active portal is used. When options are not specified, returns all groups that the active user is a member of, sorted by title in ascending order. The function requires an online portal connection and returns only groups that the user has permission to access. It returns an empty array when no groups match the search. It returns null if the request fails, such as when the portal cannot be reached.
Parameters
-
portalObject (Optional): Portal - The Portal from which to return groups. If no portal is specified, then groups from the active portal are returned.
-
options (Optional): Dictionary - Optional search options. At least one of
q,filter, orsearchmust be specified when options are provided.User Access - q: Text - The query string to search the groups against, such as
group A. - filter: Text - A structured filter specified as a field name followed by a colon and the exact term in double quotation marks, such as
title. This allows application-level filtering based on context. The specified field value must exactly match the value of interest, as partial matches may not return meaningful results.:"best group" - sortField: Text - The field by which to sort results. Supported values are
title,owner,created, andmodified. - sortOrder: Text - Determines whether the groups are returned in ascending (
asc) or descending (desc) order based on thesort. The default isField asc. - searchUserAccess: Text - Search groups by user access, such as
group.Member
- q: Text - The query string to search the groups against, such as
Return value: Array<Dictionary>
An array of dictionaries representing groups. Returns an empty array when no groups match the search, or null if the request fails, such as when the portal cannot be reached.
- id: Text - The group ID.
- title: Text - The group title.
- owner: Text - The username of the group owner.
- description: Text - The group description, or
null. - snippet: Text - A short summary of the group, or
null. - tags: Array<Text> - The tags associated with the group.
- typeKeywords: Array<Text> - The type keywords associated with the group.
- phone: Text - The contact information for the group, or
null. - created: Number - The date the group was created, represented as UNIX time in milliseconds.
- modified: Number - The date the group was last modified, represented as UNIX time in milliseconds.
- orgId: Text - The organization ID associated with the group.
Additional resources
Examples
Returns all groups that the active user is a member of, sorted by title in ascending order.
GetGroups()Searches for groups matching a full-text query.
GetGroups(Portal(), { q: "2026 urban development plans", sortField: "title", sortOrder: "asc" })GetUser
This function has 2 signatures:
- Since v1.12 - GetUser(portalObject?, username?) -> Dictionary
- Since v1.12 - GetUser(portalObject?, extensions?) -> Dictionary
GetUser(portalObject?, username?) -> Dictionary
Function bundle: Data Access
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.
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.
GetUser(Portal('https://www.arcgis.com'))GetUser(portalObject?, extensions?) -> Dictionary
Function bundle: Data Access
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
userwill be returned in the dictionary.License Type Extensions
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
extensionsparameter must be set totruein 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.
GetUser()Returns information about the user currently logged in based on the portal with user extensions.
GetUser(Portal('https://www.arcgis.com'), true)Portal
This function has 2 signatures:
- Since v1.8 - Portal(url) -> Portal
- Since v1.36 - Portal() -> Portal
Portal(url) -> Portal
Function bundle: Data Access
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
var arcgisPortal = Portal('https://www.arcgis.com');
var features = FeatureSetByPortalItem(arcgisPortal, '7b1fb95ab77f40bf8aa09c8b59045449', 0, ['Name', 'Count'], false);Enterprise Portal
Portal('https://www.example.com/arcgis')Portal() -> Portal
Function bundle: Data Access
Creates a reference to the active portal of the expression's execution context. Returns null if no active portal is available.
Return value: Portal
Example
Returns the url of the active portal of the environment where the expression executes.
Portal().url