System JS API
For advanced use cases, a JavaScript API is made available via the global zPortal object. Typically, an HTML Block is used to run JavaScript that utilizes this API. The System API provides access to data about the Portal, as well as providing methods for displaying modals, interacting with Tableau and ThoughtSpot visualizations, querying data, managing filters and parameters, and hiding and showing Blocks.
zPortal
The System API is defined on the global window object as zPortal. For most use cases, code that uses the System API is put into an HTML block inside a <script> tag. See example uses below.
.page
Information about the current page.
Type: Object
Example
{
name: "My Page",
user_id: null,
order: 1000,
icon: null,
screenshot: "data:image/png;base64,...",
id: "aabb0011-1234-5678-ccdd-aabbcc001122",
updated_at: "2020-03-30T17:02:05.906350+00:00",
created_at: "2020-03-30T17:02:05.906362+00:00",
data: {theme: {…}, grid: {…}}
datasources: [],
generateFetchResultsReport: function
}
.generateFetchResultsReport()
Opens the Fetch Results Report modal for the current page.
Type: function
Nomenclature: zPortal.page.generateFetchResultsReport() ⇒ undefined
Example
zPortal.page.generateFetchResultsReport();
.layout
(Deprecated) Use zPortal.page instead.
Information about the current page.
Type: Object
.pageList
List of each page of Portal
Type: Array
.config
The Portal configuration object containing both portal and auth configuration.
Type: Object
Example
{
portal: {
// Portal configuration state
},
auth: {
// Auth configuration state
}
}
.siteConfig
(Deprecated) Use zPortal.config instead.
The Portal Site Configuration object.
Type: Object
Example
{
system: {
theme_id: "aabb0011-1234-5678-ccdd-aabbcc001122",
default_dashboard: "aabb0011-1234-5678-ccdd-aabbcc001122",
Name: "Value"
},
openapi_url: "/openapi.json",
openapi_prefix: "/api",
debug: true,
database_url: "URL('postgresql://admin:********@172.17.0.1/portal')",
target_database_url: "URL('postgresql://admin:********@stage.zuarbase.net/analytics')",
partials: {
sidebar: {…},
rightSidebar: {…},
footer: {…},
header: {…},
leftSidebar: {…}
},
payload: {},
permissions: ["*"],
admin: true,
theme: {
id: "aabb0011-1234-5678-ccdd-aabbcc001122",
user_id: null,
name: "Light",
json_data: {…},
updated_at: "2020-03-23T10:35:05.543129+00:00"
},
tableau_server: {
url: "https://tableau.company.com",
site_name: "default",
product_version: "2020.1.1",
rest_api_version: "3.7",
build_number: "20201.20.0305.1738"
},
token_expiry: 15552000
}
.theme
Current active page theme
Type: Object
Example
{
"customProperties": {},
"template": {
"header": false,
"leftSidebar": false,
"rightSidebar": false,
"footer": false
}
}
.user
Current user object with user data and methods.
Type: Object
Example
{
logout: function,
groups: ["group1", "group2"],
// ...additional user properties
}
.logout()
Logout current user.
Type: function
Nomenclature: zPortal.user.logout() ⇒ undefined
Example
zPortal.user.logout();
.groups
List of group names the current user belongs to.
Type: string[]
Example
zPortal.user.groups;
// ["admins", "editors"]
.tableau
Set of methods designed to interact with Tableau Dashboard blocks.
.info
Tableau server configuration information.
Type: Object
Example
zPortal.tableau.info;
// {
// url: "https://tableau.company.com",
// site_name: "default",
// product_version: "2020.1.1",
// rest_api_version: "3.7",
// build_number: "20201.20.0305.1738"
// }
.regenerate()
(Deprecated) Use zPortal.tableau.setUrl instead.
Updates Tableau Dashboard Url for specified block.
Type: function
Nomenclature: zPortal.tableau.regenerate(iid, dashboardUrl) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| iid | string |
Tableau Dashboard Block's IID |
| dashboardUrl | string |
Tableau Dashboard URL to set |
Example
zPortal.tableau.regenerate('aabb0011-1234-5678-ccdd-aabbcc001122', 'https://tableau.com/t/Site/views/Workbook/View');
.getToken()
Generate JWT token using Connected App credentials
Type: function
Nomenclature: zPortal.tableau.getToken(credentials) ⇒ Promise<string>
| Param | Type | Description |
|---|---|---|
| credentials | Object |
Credentials of tableau Connected App, leave empty to use default Connected App |
Example
zPortal.tableau.getToken({
client_id:"",
secret_id:"",
secret_key:""
});
.getApiToken()
Generates Tableau API token using Connected App credentials. Check Tableau documentation for more information. Using the Credentials Token In Subsequent Calls
Type: function
Nomenclature: zPortal.tableau.getApiToken() ⇒ Promise<string>
Example
zPortal.tableau.getApiToken();
.setUrl()
Updates Tableau Dashboard Url for specified block.
Type: function
Nomenclature: zPortal.tableau.setUrl(iid, dashboardUrl) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| iid | string |
Tableau Dashboard Block's IID |
| dashboardUrl | string |
Tableau Dashboard URL to set |
Example
zPortal.tableau.setUrl('aabb0011-1234-5678-ccdd-aabbcc001122', 'https://tableau.com/t/Site/views/Workbook/View');
.getUrl()
Get Tableau Dashboard URL of specified block.
Type: function
Nomenclature: zPortal.tableau.getUrl(iid) ⇒ string
| Param | Type | Description |
|---|---|---|
| iid | string |
Tableau Dashboard Block's IID |
Example
zPortal.tableau.getUrl('aabb0011-1234-5678-ccdd-aabbcc001122');
.getViz()
Return instance of Tableau JS Viz for specified block.
Type: function
Nomenclature: zPortal.tableau.getViz(iid) ⇒ Object
| Param | Type | Description |
|---|---|---|
| iid | string |
Tableau Dashboard Block's IID |
Example
zPortal.tableau.getViz('aabb0011-1234-5678-ccdd-aabbcc001122');
.thoughtspot
Set of methods designed to interact with ThoughtSpot integrations.
.setOrg()
Change the currently selected ThoughtSpot org.
Type: function
Nomenclature: zPortal.thoughtspot.setOrg(orgId) ⇒ Promise<undefined>
| Param | Type | Description |
|---|---|---|
| orgId | string |
ThoughtSpot Org ID |
Example
zPortal.thoughtspot.setOrg('my-org-id');
.on()
Register event handler for ThoughtSpot events.
Type: function
Nomenclature: zPortal.thoughtspot.on(eventName, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
org.change |
Fires when the ThoughtSpot org changes |
Example
let callback = function () { console.log('Org changed') }
zPortal.thoughtspot.on('org.change', callback);
.off()
Removes event handler for ThoughtSpot events.
Type: function
Nomenclature: zPortal.thoughtspot.off(eventName, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
load |
Fires on ThoughtSpot load |
Example
let callback = function () { console.log('Org changed') }
zPortal.thoughtspot.on('org.change', callback);
zPortal.thoughtspot.off('load', callback);
.table
Set of methods designed to interact with Table block.
.update()
Updates Table block with new Query object.
Type: function
Nomenclature: zPortal.table.update(iid, dataObject) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| iid | string |
Table Block's IID |
| dataObject | Object |
New Query object |
Example
zPortal.table.update('aabb0011-1234-5678-ccdd-aabbcc001122', {
columns: ["*"],
order_by: "column1",
__source__: "DATASOURCE_ID"
});
.block
Set of methods designed to interact with Portal blocks.
.getData()
Get data retrieved by Query of specified block.
Type: function
Nomenclature: zPortal.block.getData(iid) ⇒ Object
| Param | Type | Description |
|---|---|---|
| iid | string |
Block's IID |
Example
zPortal.block.getData('aabb0011-1234-5678-ccdd-aabbcc001122');
.getScope()
Get the scope of an HTML block. Returns the block controller's scope, which can be used to interact with the block programmatically.
Type: function
Nomenclature: zPortal.block.getScope(iid) ⇒ Object
| Param | Type | Description |
|---|---|---|
| iid | string |
HTML Block's IID |
Example
let scope = zPortal.block.getScope('aabb0011-1234-5678-ccdd-aabbcc001122');
.show()
Shows the block with the given block id.
Type: function
Nomenclature: zPortal.block.show(iid) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| iid | string |
Block's IID |
Example
zPortal.block.show('aabb0011-1234-5678-ccdd-aabbcc001122');
.hide()
Hides the block with the given block id.
Type: function
Nomenclature: zPortal.block.hide(iid) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| iid | string |
Block's IID |
Example
zPortal.block.hide('aabb0011-1234-5678-ccdd-aabbcc001122');
.on()
Adds event listener for specific block.
Type: function
Nomenclature: zPortal.block.on(eventName, iid, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| iid | string |
Block's IID |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
load |
Fires when block loaded |
destroy |
Fires when block is being removed |
Example
let callback = function () {console.log('EVENT')}
zPortal.block.on('load', 'aabb0011-1234-5678-ccdd-aabbcc001122', callback);
.once()
Register callback that is going to be fired only once.
Type: function
Nomenclature: zPortal.block.once(eventName, iid, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| iid | string |
Block's IID |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
load |
Fires when block loaded |
destroy |
Fires when block is being removed |
Example
let callback = function () {console.log('EVENT')}
zPortal.block.once('load', 'aabb0011-1234-5678-ccdd-aabbcc001122', callback);
.off()
Removes event listener for specific block.
Type: function
Nomenclature: zPortal.block.off(eventName, iid, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| iid | string |
Block's IID |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
load |
Fires when block loaded |
destroy |
Fires when block is being removed |
Example
let callback = function () {console.log('EVENT')}
// Register callback
zPortal.block.on('load', 'aabb0011-1234-5678-ccdd-aabbcc001122', callback);
// Remove callback
zPortal.block.off('load', 'aabb0011-1234-5678-ccdd-aabbcc001122', callback);
.modal
Set of methods to configure and display modal windows.
.show()
Display a modal window. Returns a Promise that resolves when the user confirms and rejects when the user dismisses.
Type: function
Nomenclature: zPortal.modal.show(options) ⇒ Promise
| Param | Type | Description |
|---|---|---|
| options | Object |
Modal configuration object |
Options
| Param | Type | Description |
|---|---|---|
| title | String |
Title of modal window |
| body | String |
Content of modal window (supports HTML) |
| dismissButton | String |
Text to be rendered on dismiss button |
| confirmButton | String |
Text to be rendered on confirm button |
| size | String |
Enum value of modal size. (lg,md,sm) |
Example
// Show modal window
let modal = zPortal.modal.show({
title:'Modal',
body:'Hello World!',
dismissButton:'Cancel',
confirmButton:'Ok',
size:'md'
});
// Handling users interaction with window
modal
.then(function(){console.log('Modal confirmed!')})
.catch(function(){console.log('Modal dismissed!')});
.confirm()
Confirms active modal window. Same as clicking confirm button of modal window.
Type: function
Nomenclature: zPortal.modal.confirm() ⇒ undefined
Example
let modal = zPortal.modal.show({
title:'Modal',
body:'Hello World!',
dismissButton:'Cancel',
confirmButton:'Ok',
size:'md'
})
.then(function(){console.log('Modal confirmed!')})
.catch(function(){console.log('Modal dismissed!')});
// Modal is going to be confirmed.
zPortal.modal.confirm();
.dismiss()
Dismisses active modal window. Same as clicking dismiss button of modal window.
Type: function
Nomenclature: zPortal.modal.dismiss() ⇒ undefined
Example
let modal = zPortal.modal.show({
title:'Modal',
body:'Hello World!',
dismissButton:'Cancel',
confirmButton:'Ok',
size:'md'
})
.then(function(){console.log('Modal confirmed!')})
.catch(function(){console.log('Modal dismissed!')});
// Modal is going to be dismissed.
zPortal.modal.dismiss();
.partial
Set of methods designed to interact with Portal's page partials.
.slide()
Toggle animation to show or hide specified partial.
Type: function
Nomenclature: zPortal.partial.slide(partialId, direction) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| partialId | string |
Partial Id |
| direction | string |
Enum value. Defines how partial will be slided. (width,height) |
Example
zPortal.partial.slide('header', 'height');
.query
Set of methods for querying data, managing filters, and managing parameters. This is the preferred API for data operations, replacing the deprecated .dataSource methods.
.getQuery()
Gets an instance of a query by its ID. Returns a Promise that resolves to a UserQuery object with methods for data retrieval, pagination, filtering, and event handling.
Type: function
Nomenclature: zPortal.query.getQuery({ queryID }) ⇒ Promise<UserQuery>
| Param | Type | Description |
|---|---|---|
| queryID | string |
The Query ID |
Example
zPortal.query.getQuery({ queryID: 'aabb0011-1234-5678-ccdd-aabbcc001122' })
.then(function(query) {
console.log(query.getData());
});
Full Example
window.zPortal.query.getQuery({
queryID: 'my-sales-query'
}).then(query => {
// Pre-configure query if needed
// query.setPagination({ pageSize: 25 });
// query.disableFiltering();
// Setup load listener before fetching data
const cleanup = query.onLoad(() => {
console.log('Query data loaded!');
const data = query.getData();
// Process each row
data.forEach(row => {
console.log(`${row.Region}: ${row.Sales}`);
});
});
// Manually fetch data
query.fetchData();
});
UserQuery Object
The UserQuery object returned by getQuery() provides the following properties and methods:
| Property/Method | Type | Description |
|---|---|---|
enabled |
boolean |
Whether the query is enabled |
loaded |
boolean |
Whether the query has loaded |
columns |
Array |
Query columns |
parameters |
Object |
Query parameters |
pagination |
Object |
Pagination state (offset, limit, count, end) |
getData() |
function |
Returns the query's data |
getKeyValueData() |
function |
Returns data as key-value pairs |
getColumnData(...) |
function |
Returns data for specific columns |
fetchData() |
function |
Refreshes the query data |
fetchFirstPage() |
function |
Navigate to the first page |
fetchNextPage() |
function |
Navigate to the next page |
fetchPreviousPage() |
function |
Navigate to the previous page |
fetchLastPage() |
function |
Navigate to the last page |
setPagination(options) |
function |
Set pagination options |
enable() |
function |
Enable the query |
disable() |
function |
Disable the query |
enableFiltering() |
function |
Enable filtering on the query |
disableFiltering() |
function |
Disable filtering on the query |
setFilter(column, value) |
function |
Set a local filter on the query |
setRangeFilter(column, value) |
function |
Set a local range filter on the query |
removeFilter(column) |
function |
Remove a local filter from the query |
clearFilters() |
function |
Remove all local filters from the query |
onLoad(callback) |
function |
Register a callback for when the query loads |
onError(callback) |
function |
Register a callback for when the query errors |
Pagination Example
zPortal.query.getQuery({ queryID: 'aabb0011-1234-5678-ccdd-aabbcc001122' })
.then(function(query) {
// Get pagination info
console.log(query.pagination); // { offset, limit, count, end }
// Navigate pages
query.fetchNextPage();
query.fetchPreviousPage();
query.fetchFirstPage();
query.fetchLastPage();
});
Query Event Handling Example
zPortal.query.getQuery({ queryID: 'aabb0011-1234-5678-ccdd-aabbcc001122' })
.then(function(query) {
query.onLoad(function() {
console.log('Query loaded:', query.getData());
});
query.onError(function(error) {
console.error('Query error:', error);
});
query.fetchData();
});
Query-Level Filtering Example
zPortal.query.getQuery({ queryID: 'aabb0011-1234-5678-ccdd-aabbcc001122' })
.then(function(query) {
// Set a local filter on this specific query
query.setFilter('status', ['active', 'pending']);
// Set a local range filter
query.setRangeFilter('created_at', {
start: '2024-01-01T00:00:00Z',
end: '2024-12-31T23:59:59Z'
});
// Remove a specific filter
query.removeFilter('status');
// Clear all local filters
query.clearFilters();
// Refresh to apply changes
query.fetchData();
});
.getFilters()
Returns all currently applied global filters as an object mapping column names to arrays of values.
Type: function
Nomenclature: zPortal.query.getFilters() ⇒ Object
Returns: Object — An object where keys are column names and values are arrays of applied filter values. Returns an empty object {} if no filters are applied.
Example
// No filters applied
zPortal.query.getFilters();
// Returns: {}
// With filters applied
zPortal.query.getFilters();
// Returns: { "bikeshop_state": ["AZ"], "bikeshop_name": ["Ithaca Mountain Climbers"] }
.getFilter()
Returns the applied filter values for a specific column.
Type: function
Nomenclature: zPortal.query.getFilter(column) ⇒ string[] | undefined
| Param | Type | Description |
|---|---|---|
| column | string |
Column name |
Returns: string[] | undefined — An array of filter values for the column, or undefined if no filter is applied for that column.
Example
zPortal.query.getFilter('bikeshop_state');
// Returns: ['AZ']
zPortal.query.getFilter('nonexistent_column');
// Returns: undefined
.getRangeFilters()
Returns all currently applied range filters as an object mapping column names to range objects.
Type: function
Nomenclature: zPortal.query.getRangeFilters() ⇒ Object
Returns: Object — An object where keys are column names and values are objects with start and end properties in ISO datetime format. Returns an empty object {} if no range filters are applied.
Example
// No range filters applied
zPortal.query.getRangeFilters();
// Returns: {}
// With a date range filter applied
zPortal.query.getRangeFilters();
// Returns: { "event_date": { "start": "2026-03-30T08:05:31.484Z", "end": "2026-04-30T08:05:31.484Z" } }
.getRangeFilter()
Returns the applied range filter for a specific column.
Type: function
Nomenclature: zPortal.query.getRangeFilter(column) ⇒ Object | undefined
| Param | Type | Description |
|---|---|---|
| column | string |
Column name |
Returns: Object | undefined — An object with start and end properties in ISO datetime format, or undefined if no range filter is applied for that column.
Example
zPortal.query.getRangeFilter('event_date');
// Returns: { "start": "2026-03-30T08:05:31.484Z", "end": "2026-04-30T08:05:31.484Z" }
zPortal.query.getRangeFilter('nonexistent_column');
// Returns: undefined
.getParameters()
Returns all currently applied parameters as an object mapping parameter names to arrays of values.
Type: function
Nomenclature: zPortal.query.getParameters() ⇒ Object
Returns: Object — An object where keys are parameter names and values are arrays of applied parameter values. Returns an empty object {} if no parameters are applied.
Example
// No parameters applied
zPortal.query.getParameters();
// Returns: {}
// With parameters applied
zPortal.query.getParameters();
// Returns: { "bs": ["AZ", "OH"] }
.getParameter()
Returns the applied value for a specific parameter.
Type: function
Nomenclature: zPortal.query.getParameter(name) ⇒ string[] | undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Parameter name |
Returns: string[] | undefined — An array of parameter values, or undefined if the parameter is not set.
Example
zPortal.query.getParameter('bs');
// Returns: ["AZ"]
zPortal.query.getParameter('unset_param');
// Returns: undefined
.setFilter()
Sets a global filter value for all active datasources.
Type: function
Nomenclature: zPortal.query.setFilter(name, values) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Column name |
| values | string | string[] |
Filter values |
Example
zPortal.query.setFilter('country', ['US', 'CA']);
.setRangeFilter()
Sets a global range filter for all active datasources.
Type: function
Nomenclature: zPortal.query.setRangeFilter(name, values) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Column name |
| values | Object |
Filter range value {start: <ISODateTimeFormat>, end: <ISODateTimeFormat>} |
Example
zPortal.query.setRangeFilter('created_at', {
start: '2024-01-01T00:00:00Z',
end: '2024-12-31T23:59:59Z'
});
.removeFilter()
Removes a specific global filter by column name.
Type: function
Nomenclature: zPortal.query.removeFilter(name) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Column name |
Example
zPortal.query.removeFilter('country');
.clearFilters()
Removes all applied global filters.
Type: function
Nomenclature: zPortal.query.clearFilters() ⇒ undefined
Example
zPortal.query.clearFilters();
.setParameter()
Sets a parameter value.
Type: function
Nomenclature: zPortal.query.setParameter(name, values) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Parameter name |
| values | string | string[] |
Parameter values |
Example
zPortal.query.setParameter('region', 'west');
.removeParameter()
Removes a specific parameter by name.
Type: function
Nomenclature: zPortal.query.removeParameter(name) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Parameter name |
Example
zPortal.query.removeParameter('region');
.clearParameters()
Removes all applied parameters.
Type: function
Nomenclature: zPortal.query.clearParameters() ⇒ undefined
Example
zPortal.query.clearParameters();
.dataSource
(Deprecated) Use zPortal.query instead.
Set of methods designed to interact with Portal's data source system. All methods in this namespace are deprecated.
.get()
(Deprecated) Use zPortal.query.getQuery() instead.
Gets instance of Datasource.
Type: function
Nomenclature: zPortal.dataSource.get(id) ⇒ Object
| Param | Type | Description |
|---|---|---|
| id | string |
Datasource ID |
Example
zPortal.dataSource.get('aabb0011-1234-5678-ccdd-aabbcc001122');
.addQuery()
(Deprecated) Use zPortal.query.getQuery() instead.
Adds new Query.
Type: function
Nomenclature: zPortal.dataSource.addQuery(query) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| query | Object |
Query object |
Example
zPortal.dataSource.addQuery({
columns: ["*"],
order_by: "column1",
__source__: "DATASOURCE_ID"
});
.fetchResults()
(Deprecated) Use zPortal.query.getQuery() instead.
Fetch data using Query object, without adding query to datasource.
Type: function
Nomenclature: zPortal.dataSource.fetchResults(query) ⇒ Object
| Param | Type | Description |
|---|---|---|
| query | Object |
Query object |
Example
zPortal.dataSource.fetchResults({
columns: ["*"],
order_by: "column1",
__source__: "DATASOURCE_ID"
});
.setFilters()
(Deprecated) Use zPortal.query.setFilter() instead.
Sets filter values for all active datasources.
Type: function
Nomenclature: zPortal.dataSource.setFilters(name, values) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Column name |
| values | string | string[] |
Filter values |
Example
zPortal.dataSource.setFilters('country', ['US', 'CA']);
.setRangeFilters()
(Deprecated) Use zPortal.query.setRangeFilter() instead.
Sets range filter values for all active datasources.
Type: function
Nomenclature: zPortal.dataSource.setRangeFilters(name, values) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| name | string |
Column name |
| values | Object |
Filter range value {start: <ISODateTimeFormat>, end: <ISODateTimeFormat>} |
Example
zPortal.dataSource.setRangeFilters('created_at', {
start: '2024-01-01T00:00:00Z',
end: '2024-12-31T23:59:59Z'
});
.clearFilters()
(Deprecated) Use zPortal.query.clearFilters() instead.
Removes all applied filters.
Type: function
Nomenclature: zPortal.dataSource.clearFilters() ⇒ undefined
Example
zPortal.dataSource.clearFilters();
.on()
(Deprecated) Use zPortal.query.getQuery() with onLoad() instead.
Register event handler for data source events.
Type: function
Nomenclature: zPortal.dataSource.on(eventName, datasourceID, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| datasourceID | string |
Datasource ID |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
load |
Fires when datasource loaded |
Example
let callback = function () {console.log('Datasource loaded')}
zPortal.dataSource.on('load', 'aabb0011-1234-5678-ccdd-aabbcc001122', callback);
.off()
(Deprecated) Use zPortal.query.getQuery() with onLoad() instead.
Removes event handler for data source events.
Type: function
Nomenclature: zPortal.dataSource.off(eventName, datasourceID, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| datasourceID | string |
Datasource ID |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
load |
Fires when datasource loaded |
Example
let callback = function () {console.log('Datasource loaded')}
// Register callback
zPortal.dataSource.on('load', 'aabb0011-1234-5678-ccdd-aabbcc001122', callback);
// Remove callback
zPortal.dataSource.off('load', 'aabb0011-1234-5678-ccdd-aabbcc001122', callback);
.assets
Set of methods for interacting with Portal's file assets.
.fetch()
Retrieve a list of assets at the specified path.
Type: function
Nomenclature: zPortal.assets.fetch(path, options) ⇒ Promise<Object>
| Param | Type | Description |
|---|---|---|
| path | string | string[] |
Target path as a string or array of path segments |
| options | Object |
Optional pagination options |
| options.next_page_token | string |
Token for fetching the next page of results |
| options.limit | number |
Maximum number of items to return |
Returns: Promise<{ items, next_page_token }>
Example
// Fetch assets at root
zPortal.assets.fetch('').then(function(result) {
console.log(result.items);
});
// Fetch assets in a subdirectory with pagination
zPortal.assets.fetch('images/icons', { limit: 10 }).then(function(result) {
console.log(result.items);
if (result.next_page_token) {
// Fetch next page
zPortal.assets.fetch('images/icons', { next_page_token: result.next_page_token });
}
});
// Using array path segments
zPortal.assets.fetch(['images', 'icons']);
.resources
Set of methods for loading external resources.
.load()
Load one or more external resources.
Type: function
Nomenclature: zPortal.resources.load(resources) ⇒ Promise
| Param | Type | Description |
|---|---|---|
| resources | string | string[] |
Resource or list of resources to load |
Example
// Load a single resource
zPortal.resources.load('my-resource');
// Load multiple resources
zPortal.resources.load(['resource-1', 'resource-2']);
.export
Set of methods for exporting Portal content.
.pdf()
Export the current page as a PDF.
Type: function
Nomenclature: zPortal.export.pdf() ⇒ undefined
Example
zPortal.export.pdf();
.translations
Set of methods designed to interact with Portal's translations system.
.get()
Gets list of all translations.
Type: function
Nomenclature: zPortal.translations.get() ⇒ Object[]
Example
zPortal.translations.get();
.on()
Register event handler for translations events.
Type: function
Nomenclature: zPortal.translations.on(eventName, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
change |
Fires when translation changes |
Example
let callback = function () {console.log('Translation changed')}
// Register callback
zPortal.translations.on('change', callback);
.off()
Removes event handler for translations events.
Type: function
Nomenclature: zPortal.translations.off(eventName, callback) ⇒ undefined
| Param | Type | Description |
|---|---|---|
| eventName | string |
Event name |
| callback | Function |
Event handler |
Events
| Event | Description |
|---|---|
change |
Fires when translation changes |
Example
let callback = function () {console.log('Translation changed')}
// Register callback
zPortal.translations.on('change', callback);
// Remove callback
zPortal.translations.off('change', callback);