Skip To ContentArcGIS for DevelopersSign In Dashboard
require(["esri/portal/Portal"], function(Portal) { /* code goes here */ });
Class: esri/portal/Portal
Inheritance: Portal Accessor
Since: ArcGIS API for JavaScript 4.0

The Portal class is part of the ArcGIS Enterprise portal that provides a way to build applications that work with content from ArcGIS Online or an ArcGIS Enterprise portal. ArcGIS Enterprise is software from Esri that customers can deploy either on-premises or in the cloud. ArcGIS Online is Esri's Software as a Service offering that represents GIS as a Service and is implemented using the same technology as ArcGIS Enterprise.

The Portal API allows application developers to work with users, groups and content hosted within ArcGIS Online or within an ArcGIS Enterprise portal. The API allows developers to build web, mobile, and desktop applications that support sharing and collaboration using web maps. Organizational developers can also use the API to build custom applications for their users.

The Portal class provides a view of the portal as seen by the current user, anonymous or logged in. Includes information such as the name, logo, featured items and supported protocols (http vs https) for this portal. If the user is not logged in, this call will return the default view of the portal. If the user is logged in, the view of the portal returned will be specific to the organization that the user belongs to. The default view of the portal is dependent on the culture of the user that is obtained from the users profile.

The when() method on the Portal instance can be called to execute processes that may only run after the Portal is loaded.

// load the Portal and PortalQueryParams modules
require(["esri/portal/Portal",
 "esri/portal/PortalQueryParams"
], function(Portal, PortalQueryParams) {
  portal = new Portal();
  // Setting authMode to immediate signs the user in once loaded
  portal.authMode = "immediate";

  // Once portal is loaded, user signed in
  portal.load().then(function() {
    console.log(portal);

    // Create query parameters for the portal search
    // This object autocasts as new PortalQueryParams()
    var queryParams = {
      query: "owner:" + portal.user.username,
      sortField: "numViews",
      sortOrder: "desc",
      num: 20
    };
    // Query the items based on the queryParams created from portal above
    portal.queryItems(queryParams).then(createGallery);
  });
});
See also:

Constructors

new Portal(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String

The access level of the organization.

more details
more detailsPortal
Boolean

When true, access to the organization's Portal resources must occur over SSL.

more details
more detailsPortal
String

The authentication mode for handling authentication when the user attempts to access a secure resource.

more details
more detailsPortal
String[]

Array of trusted servers to send credentials to when making Cross-Origin Resource Sharing (CORS) requests to access services secured with web-tier authentication.

more details
more detailsPortal
String

The query that defines the basemaps that should be displayed in the BasemapGallery when useVectorBasemaps is not true.

more details
more detailsPortal
String

The Bing key to use for web maps using Bing Maps.

more details
more detailsPortal
Boolean

Indicates whether an organization can list applications in the marketplace.

more details
more detailsPortal
Boolean

Indicates whether an organization can list data services in the marketplace.

more details
more detailsPortal
Boolean

Indicates whether an organization can list pre-provisioned items in the marketplace.

more details
more detailsPortal
Boolean

Indicates whether an organization can provision direct purchases in the marketplace without customer request.

more details
more detailsPortal
Boolean

When true, the organization's public items, groups and users are included in search queries.

more details
more detailsPortal
Boolean

The Bing key can be shared to the public and is returned as part of a portal's description call (/sharing/rest/portals/<orgid>).

more details
more detailsPortal
Boolean

When true, members of the organization can share resources outside the organization.

more details
more detailsPortal
Boolean

Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the ArcGIS sign in.

more details
more detailsPortal
Boolean

Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the enterprise sign in.

more details
more detailsPortal
String

The query that identifies the group containing the color sets used for rendering in the map viewer.

more details
more detailsPortal
Boolean

Indicates whether to allow the organization to disable commenting.

more details
more detailsPortal
Date

Date the organization was created.

more details
more detailsPortal
String

The default locale (language and country) information.

more details
more detailsPortal
String

The custom base URL for the portal.

more details
more detailsPortal
String

The name of the class.

more details
more detailsAccessor
Basemap

The default basemap to use for the portal.

more details
more detailsPortal
Extent

The default extent to use for the portal.

more details
more detailsPortal
Basemap

The default vector basemap to use for the portal.

more details
more detailsPortal
String

A description of the organization/portal.

more details
more detailsPortal
Boolean

Boolean value indicating whether to opt-in to the Esri User Experience Improvement (EUEI) program.

more details
more detailsPortal
Object[]

The featured groups for the portal.

more details
more detailsPortal
String

The query that defines the featured group.

more details
more detailsPortal
String

The query that identifies the group containing features items for the gallery.

more details
more detailsPortal
Boolean

Indicates whether the organization has content categories.

more details
more detailsPortal
Object

Helper services provided by the portal.

more details
more detailsPortal
String

The group that contains featured content to be displayed on the home page.

more details
more detailsPortal
Number

The number of featured items that can be displayed on the home page.

more details
more detailsPortal
Number

The port used by the portal for HTTP communication.

more details
more detailsPortal
Number

The port used by the portal for HTTPS communication.

more details
more detailsPortal
String

The id of the organization that owns this portal.

more details
more detailsPortal
String

The country code of the calling IP (ArcGIS Online only).

more details
more detailsPortal
Boolean

Indicates whether the portal is an organization.

more details
more detailsPortal
Boolean

Indicates if the portal is on-premises.

more details
more detailsPortal
String

The query that identifies the group containing editing templates.

more details
more detailsPortal
Boolean

Indicates whether the portal's resources have loaded.

more details
more detailsPortal
Error

The Error object returned if an error occurred while loading.

more details
more detailsPortal
String

Represents the status of a load operation.

more details
more detailsPortal
Object[]

A list of warnings which occurred while loading.

more details
more detailsPortal
Number

The maximum validity in minutes of tokens issued for users of the organization.

more details
more detailsPortal
Date

Date the organization was last modified.

more details
more detailsPortal
String

Name of the organization.

more details
more detailsPortal
String

URL of the portal host.

more details
more detailsPortal
String

The portal mode.

more details
more detailsPortal
Object

Properties specific to the organization, for example the "contact us" link.

more details
more detailsPortal
String

The region for the organization.

more details
more detailsPortal
String

The REST URL for the portal, for example "https://www.arcgis.com/sharing/rest" for ArcGIS Online and "https://www.example.com/arcgis/sharing/rest" for your in-house portal.

more details
more detailsPortal
Object[]

Custom HTML for the home page.

more details
more detailsPortal
Boolean

Indicates whether the description of your organization displays on the home page.

more details
more detailsPortal
Boolean

Indicates whether hosted services are supported.

more details
more detailsPortal
String

The query that defines the symbols sets.

more details
more detailsPortal
String

The query that defines the collection of templates that will appear in the template gallery.

more details
more detailsPortal
String

The URL to the thumbnail of the organization.

more details
more detailsPortal
String

Sets the units of measure for the organization's users.

more details
more detailsPortal
String

The URL to the portal instance.

more details
more detailsPortal
String

The prefix selected by the organization's administrator to be used with the customBaseURL.

more details
more detailsPortal
PortalUser

Information representing a registered user of the portal.

more details
more detailsPortal
Boolean

When true, only simple where clauses that are compliant with SQL92 can be used when querying layers and tables.

more details
more detailsPortal
Boolean

When true, the organization has opted in to use the vector tile basemaps, and (a) vectorBasemapGalleryGroupQuery should be used instead of basemapGalleryGroupQuery, while (b) defaultVectorBasemap should be used instead of defaultBasemap.

more details
more detailsPortal
String

The query that defines the vector tiles basemaps that should be displayed in the BasemapGallery when useVectorBasemaps is true.

more details
more detailsPortal

Property Details

access String

The access level of the organization. When public, anonymous users can access the organization. When private, access is restricted to only members of the organization.

Possible Values: public | private

allSSL Boolean

When true, access to the organization's Portal resources must occur over SSL.

authMode String

The authentication mode for handling authentication when the user attempts to access a secure resource.

Possible ValueDescription
anonymousAn error will be returned when a secure resource is requested.
autoThe user will be signed in when a secure resource is requested.
immediateThe user will be signed in when the Portal is loaded.
Default Value:auto
authorizedCrossOriginDomains String[]

Array of trusted servers to send credentials to when making Cross-Origin Resource Sharing (CORS) requests to access services secured with web-tier authentication.

basemapGalleryGroupQuery String
Since: ArcGIS API for JavaScript 4.4

The query that defines the basemaps that should be displayed in the BasemapGallery when useVectorBasemaps is not true. The fetchBasemaps() method does this automatically.

bingKey String

The Bing key to use for web maps using Bing Maps.

canListApps Boolean

Indicates whether an organization can list applications in the marketplace.

canListData Boolean

Indicates whether an organization can list data services in the marketplace.

canListPreProvisionedItems Boolean

Indicates whether an organization can list pre-provisioned items in the marketplace.

canProvisionDirectPurchase Boolean

Indicates whether an organization can provision direct purchases in the marketplace without customer request.

canSearchPublic Boolean

When true, the organization's public items, groups and users are included in search queries. When false, no public items outside of the organization are included. However, public items which are part of the organization are included.

Default Value:true
canShareBingPublic Boolean

The Bing key can be shared to the public and is returned as part of a portal's description call (/sharing/rest/portals/<orgid>). This requires the access of the portal to be set to public. The canShareBingPublic property is not returned publicly but only shown to users within the organization.

Default Value:false
canSharePublic Boolean

When true, members of the organization can share resources outside the organization.

Default Value:false
canSignInArcGIS Boolean

Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the ArcGIS sign in.

Default Value:false
canSignInIDP Boolean

Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the enterprise sign in.

Default Value:false
colorSetsGroupQuery String

The query that identifies the group containing the color sets used for rendering in the map viewer.

commentsEnabled Boolean

Indicates whether to allow the organization to disable commenting. When commentsEnabled is false, comments are hidden and not removed. numComments are set to zero for all items in the organization. Calls to add a comment and view comments will fail. If the organization re-enables comments, the comments display and numComments are restored.

Default Value:false
created Date

Date the organization was created.

culture String

The default locale (language and country) information.

customBaseUrl String

The custom base URL for the portal.

declaredClass Stringreadonly inherited
Since: ArcGIS API for JavaScript 4.7

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

defaultBasemap Basemap

The default basemap to use for the portal. Used in the map viewer.

defaultExtent Extent

The default extent to use for the portal. Used in the map viewer. The extent will be in the default basemap's spatial reference.

defaultVectorBasemap Basemap
Since: ArcGIS API for JavaScript 4.4

The default vector basemap to use for the portal. Used in the map viewer.

description String

A description of the organization/portal.

eueiEnabled Boolean
Since: ArcGIS API for JavaScript 4.7

Boolean value indicating whether to opt-in to the Esri User Experience Improvement (EUEI) program.

Default Value:false
featuredGroups Object[]

The featured groups for the portal. Returns an array of objects that provide access to the owner and title for each featured group. Each item in this array has the following specification:

Properties:
owner String

Name of the group owner.

title String

Group title.

featuredItemsGroupQuery String

The query that defines the featured group. If null, then the most viewed items in the organization will be the featured items.

galleryTemplatesGroupQuery String

The query that identifies the group containing features items for the gallery. Set a Group ID or, if null, then the most viewed items in your organization are displayed in the gallery.

hasCategorySchema Boolean
Since: ArcGIS API for JavaScript 4.8

Indicates whether the organization has content categories.

Default Value:false
helperServices Object
Since: ArcGIS API for JavaScript 4.4

Helper services provided by the portal. This is useful in instances where helper services are needed but may not be available using the given helper methods createClosestFacilityTask, createElevationLayers, createGeometryService, createPrintTask, createRouteTask, and createServiceAreaTask.

For additional information about helper services, see the about utility services topic from the ArcGIS Server documentation.

homePageFeaturedContent String

The group that contains featured content to be displayed on the home page.

homePageFeaturedContentCount Number

The number of featured items that can be displayed on the home page. The max is 100. Accepts integers only.

httpPort Number

The port used by the portal for HTTP communication.

httpsPort Number

The port used by the portal for HTTPS communication.

The id of the organization that owns this portal. If null then this is the default portal for anonymous and non-organizational users.

ipCntryCode String

The country code of the calling IP (ArcGIS Online only).

isOrganization Booleanreadonly

Indicates whether the portal is an organization.

isPortal Boolean

Indicates if the portal is on-premises.

layerTemplatesGroupQuery String

The query that identifies the group containing editing templates.

loaded Booleanreadonly

Indicates whether the portal's resources have loaded. When true, all the properties of the object can be accessed.

Default Value:false
loadError Errorreadonly

The Error object returned if an error occurred while loading.

Default Value:null
loadStatus Stringreadonly

Represents the status of a load operation.

ValueDescription
not-loadedThe object's resources have not loaded.
loadingThe object's resources are currently loading.
loadedThe object's resources have loaded without errors.
failedThe object's resources failed to load. See loadError for more details.
Default Value:not-loaded
loadWarnings Object[]readonly

A list of warnings which occurred while loading.

maxTokenExpirationMinutes Number

The maximum validity in minutes of tokens issued for users of the organization. -1 is the default and is a special value that indicates infinite timeout or permanent tokens. For tokens granted using OAuth 2.0 authorization grant, it represents the maximum validity of refresh tokens. For access tokens, the maximum validity is the lower of two weeks or this value.

modified Date

Date the organization was last modified.

name String

Name of the organization.

portalHostname String

URL of the portal host.

portalMode String

The portal mode.

Possible Values: multitenant | singletenant

portalProperties Object

Properties specific to the organization, for example the "contact us" link. If the organization is public, the properties are visible to the anonymous user.

region String

The region for the organization.

restUrl Stringreadonly

The REST URL for the portal, for example "https://www.arcgis.com/sharing/rest" for ArcGIS Online and "https://www.example.com/arcgis/sharing/rest" for your in-house portal.

rotatorPanels Object[]

Custom HTML for the home page.

showHomePageDescription Boolean

Indicates whether the description of your organization displays on the home page.

supportsHostedServices Boolean

Indicates whether hosted services are supported.

Default Value:false
symbolSetsGroupQuery String

The query that defines the symbols sets.

templatesGroupQuery String

The query that defines the collection of templates that will appear in the template gallery.

thumbnailUrl Stringreadonly

The URL to the thumbnail of the organization.

units String

Sets the units of measure for the organization's users. The user default is derived from the organization's region.

Possible Values: english | metric

url String

The URL to the portal instance. Setting the location of the portal instance via esriConfig.portalUrl should be used in favor of setting it directly on this property.

If using an on-premise portal, the syntax should look similar to: https://www.example.com/arcgis

Default Value:esriConfig.portalUrl
urlKey String

The prefix selected by the organization's administrator to be used with the customBaseURL.

Information representing a registered user of the portal.

useStandardizedQuery Boolean

When true, only simple where clauses that are compliant with SQL92 can be used when querying layers and tables. The recommended security setting is true.

useVectorBasemaps Boolean
Since: ArcGIS API for JavaScript 4.4

When true, the organization has opted in to use the vector tile basemaps, and (a) vectorBasemapGalleryGroupQuery should be used instead of basemapGalleryGroupQuery, while (b) defaultVectorBasemap should be used instead of defaultBasemap. The fetchBasemaps() method automatically uses vectorBasemapGalleryGroupQuery.

vectorBasemapGalleryGroupQuery String
Since: ArcGIS API for JavaScript 4.4

The query that defines the vector tiles basemaps that should be displayed in the BasemapGallery when useVectorBasemaps is true. The fetchBasemaps() method does this automatically.

Method Overview

NameReturn TypeSummaryClass

Cancels a load() operation if it is already in progress.

more details
more detailsPortal
Promise<ClosestFacilityTask>

A helper function that returns an instance of the portal's ClosestFacilityTask helper service.

more details
more detailsPortal
Promise<ElevationLayer[]>

A helper function that returns an array of ElevationsLayers derived from the Portal's Limited Error Raster Compression (LERC) elevation helper service.

more details
more detailsPortal
Promise<GeometryService>

A helper function that returns an instance of the portal's GeometryService helper service.

more details
more detailsPortal
Promise<PrintTask>

A helper function that returns an instance of the portal's PrintTask helper service.

more details
more detailsPortal
Promise<RouteTask>

A helper function that returns an instance of the portal's RouteTask helper service.

more details
more detailsPortal
Promise<ServiceAreaTask>

A helper function that returns an instance of the portal's ServiceAreaTask helper service.

more details
more detailsPortal
Promise<Basemap[]>

Fetches the basemaps that are displayed in the BasemapGallery.

more details
more detailsPortal
Promise<Object[]>

If present, fetches the organization's category schema.

more details
more detailsPortal
Promise<PortalGroup[]>

Fetches the featured groups in the Portal.

more details
more detailsPortal
Promise<Object[]>

Fetches and returns the associated regions with the portal instance.

more details
more detailsPortal
Portal

Returns a cached default Portal instance.

more details
more detailsPortal
Boolean

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).

more details
more detailsPortal
Boolean

isRejected() may be used to verify if creating an instance of the class is rejected.

more details
more detailsPortal
Boolean

isResolved() may be used to verify if creating an instance of the class is resolved.

more details
more detailsPortal
Promise

Loads the resources referenced by this class.

more details
more detailsPortal
Promise<PortalQueryResult>

Executes a query against the Portal to return an array of PortalGroup objects that match the input query.

more details
more detailsPortal
Promise<PortalQueryResult>

Executes a query against the Portal to return an array of PortalItem objects that match the input query.

more details
more detailsPortal
Promise<PortalQueryResult>

Executes a query against the Portal to return an array of PortalUser objects that match the input query.

more details
more detailsPortal
Promise

when() may be leveraged once an instance of the class is created.

more details
more detailsPortal

Method Details

cancelLoad()

Cancels a load() operation if it is already in progress.

createClosestFacilityTask(){Promise<ClosestFacilityTask>}
Since: ArcGIS API for JavaScript 4.12

A helper function that returns an instance of the portal's ClosestFacilityTask helper service.

Returns:
TypeDescription
Promise<ClosestFacilityTask>When resolved, returns an instance of the ClosestFacilityTask.
See also:
createElevationLayers(){Promise<ElevationLayer[]>}
Since: ArcGIS API for JavaScript 4.12

A helper function that returns an array of ElevationsLayers derived from the Portal's Limited Error Raster Compression (LERC) elevation helper service.

Returns:
TypeDescription
Promise<ElevationLayer[]>When resolved, returns an array of ElevationLayers.
See also:
createGeometryService(){Promise<GeometryService>}
Since: ArcGIS API for JavaScript 4.12

A helper function that returns an instance of the portal's GeometryService helper service.

Returns:
TypeDescription
Promise<GeometryService>When resolved, returns an instance of GeometryService.
See also:
createPrintTask(){Promise<PrintTask>}
Since: ArcGIS API for JavaScript 4.12

A helper function that returns an instance of the portal's PrintTask helper service.

Returns:
TypeDescription
Promise<PrintTask>When resolved, returns an instance of PrintTask.
See also:
createRouteTask(){Promise<RouteTask>}
Since: ArcGIS API for JavaScript 4.12

A helper function that returns an instance of the portal's RouteTask helper service.

Returns:
TypeDescription
Promise<RouteTask>When resolved, returns an instance of RouteTask.
See also:
createServiceAreaTask(){Promise<ServiceAreaTask>}
Since: ArcGIS API for JavaScript 4.12

A helper function that returns an instance of the portal's ServiceAreaTask helper service.

Returns:
TypeDescription
Promise<ServiceAreaTask>When resolved, returns an instance of ServiceAreaTask.
See also:
fetchBasemaps(basemapGalleryGroupQuery, options){Promise<Basemap[]>}

Fetches the basemaps that are displayed in the BasemapGallery. When useVectorBasemaps is true, the basemaps will be based on vectorBasemapGalleryGroupQuery. Otherwise, it is based on basemapGalleryGroupQuery.

Parameters:
basemapGalleryGroupQuery String
optional

When provided, this argument is used to fetch basemaps based on input query parameters.

options Object
optional

An object with the following properties.

Specification:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
Promise<Basemap[]>Resolves to an array of Basemap objects representing the basemaps used in the Basemap Gallery of the Portal.
Example:
portal.fetchBasemaps("title:\"Cloud Creek Basemaps\" AND owner:jsmith")
 .then(function(basemaps){
   // do something with the basemaps
 });
fetchCategorySchema(options){Promise<Object[]>}
Since: ArcGIS API for JavaScript 4.8

If present, fetches the organization's category schema.

Parameters:
options Object
optional

An object with the following properties.

Specification:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
Promise<Object[]>Resolves to an array of objects containing the following properties:
PropertyTypeDescription
titlestringThe title of the category schema.
categoriesobject[]An array of objects containing a title and an array of categories.
Example:
// Fetches the category schema
portal.fetchCategorySchema().then(function(schemas){
  schemas.forEach(function(schema){
    console.log("schema: ", schema);
  });
});
fetchFeaturedGroups(options){Promise<PortalGroup[]>}

Fetches the featured groups in the Portal.

Parameters:
options Object
optional

An object with the following properties.

Specification:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
Promise<PortalGroup[]>Resolves to an array of PortalGroup objects.
Example:
// fetch featured groups
portal.fetchFeaturedGroups().then(function(groups){
   groups.forEach(function(group){
     group.fetchMembers().then(function(members){
       console.log("member", members);
     });
   });
});
fetchRegions(options){Promise<Object[]>}
Since: ArcGIS API for JavaScript 4.8

Fetches and returns the associated regions with the portal instance.

Parameters:
options Object
optional

An object with the following properties.

Specification:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
Promise<Object[]>Resolves to an array of objects containing the following properties:
PropertyTypeDescription
localizedNamestringThe localized name for the region. For example, "Australia".
namestringThe name of the region. For example, "Australia".
regionstringRegion name. For example, "AU".
See also:
getDefault(){Portal}static

Returns a cached default Portal instance.

Returns:
TypeDescription
PortalThe Portal instance.
isFulfilled(){Boolean}

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled, true will be returned.

Returns:
TypeDescription
BooleanIndicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected(){Boolean}

isRejected() may be used to verify if creating an instance of the class is rejected. If it is rejected, true will be returned.

Returns:
TypeDescription
BooleanIndicates whether creating an instance of the class has been rejected.
isResolved(){Boolean}

isResolved() may be used to verify if creating an instance of the class is resolved. If it is resolved, true will be returned.

Returns:
TypeDescription
BooleanIndicates whether creating an instance of the class has been resolved.
load(signal){Promise}

Loads the resources referenced by this class. This method automatically executes for a View and all of the resources it references in Map if the view is constructed with a map instance.

This method must be called by the developer when accessing a resource that will not be loaded in a View.

It's possible to provide a signal to stop being interested into a Loadable instance load status. When the signal is aborted, the instance does not stop its loading process, only cancelLoad can abort it.

Parameter:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
PromiseResolves when the resources have loaded.
queryGroups(queryParams, options){Promise<PortalQueryResult>}

Executes a query against the Portal to return an array of PortalGroup objects that match the input query.

Parameters:
Autocasts from Object

The input query parameters defined in PortalQueryParams.

options Object
optional

An object with the following properties.

Specification:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
Promise<PortalQueryResult>When resolved, resolves to an instance of PortalQueryResult which contains a results array of PortalGroup objects representing all the groups that match the input query.
See also:
queryItems(queryParams, options){Promise<PortalQueryResult>}

Executes a query against the Portal to return an array of PortalItem objects that match the input query.

Parameters:
Autocasts from Object

The input query parameters defined in PortalQueryParams.

options Object
optional

An object with the following properties.

Specification:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
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.
See also:
Example:
// Once portal is loaded, user signed in
  portal.load().then(function() {
    console.log(portal);

    // Create query parameters for the portal search
    // This object autocasts as new PortalQueryParams()
    var queryParams = {
      query: "owner:" + portal.user.username,
      sortField: "numViews",
      sortOrder: "desc",
      num: 20
    };

    // Query the items based on the queryParams created from portal above
    portal.queryItems(queryParams).then(createGallery);
  });
queryUsers(queryParams, options){Promise<PortalQueryResult>}

Executes a query against the Portal to return an array of PortalUser objects that match the input query.

Parameters:
Autocasts from Object

The input query parameters defined in PortalQueryParams.

options Object
optional

An object with the following properties.

Specification:
optional

Signal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named AbortError when an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.

Returns:
TypeDescription
Promise<PortalQueryResult>When resolved, resolves to an instance of PortalQueryResult which contains a results array of PortalUser objects representing all the items that match the input query.
See also:
Example:
// Once portal is loaded, user signed in
portal.load().then(function() {
   // queryUsers
   // This object autocasts as new PortalQueryParams()
   var queryParameters = {
     query: "username:" + portal.user.username
   };

   portal.queryUsers(queryParameters).then(function(queryResults){
     queryResults.results[0].fetchFolders().then(function(folders){
       folders.forEach(function(folder){
         console.log(" user folder", folder.title);
       });
     });
   });
});
when(callback, errback){Promise}
Since: ArcGIS API for JavaScript 4.6

when() may be leveraged once an instance of the class is created. This method takes two input parameters: a callback function and an errback function. The callback executes when the instance of the class loads. The errback executes if the instance of the class fails to load.

Parameters:
callback Function
optional

The function to call when the promise resolves.

errback Function
optional

The function to execute when the promise fails.

Returns:
TypeDescription
PromiseReturns a new promise for the result of callback that may be used to chain additional functions.
Example:
// Although this example uses MapView, any class instance that is a promise may use then() in the same way
var view = new MapView();
view.when(function(){
  // This function will execute once the promise is resolved
}, function(error){
  // This function will execute if the promise is rejected due to an error
});

API Reference search results

NameTypeModule
Loading...