Skip to content
Reference > Classes

Session

Definition

Session var = .... ;

Extends

Extended By

None

Description

Represents the session for this user's login. There is a global variable 'session' that implements a Session instance and can be used for accessing session level objects such as properties, panels, datamodels, etc.

Method Summary

Owner Name Return Type Description
Session alert(alertText, closeButtonTextAndTitleText) String Shows alert dialog with given text. The second and third arguments are optional. Returns null.
Session callCommand(appId, commandId, table) String Calls a command (asynchronously) and returns the command uid. If the command has no route, then null is returned. See callback Layout::onAsyncCommandResponse(...) for processing the response once it's available. WARNING: If multiple commands are registered under the same appId and commandId then it will call the first
Session callCommand(appId, commandId, table, timeoutMillis) String Calls a command (asynchronously) and returns the command uid. If the command has no route, then null is returned. See callback Layout::onAsyncCommandResponse(...) for processing the response once it's available.
Session callCommandSync(appId, commandId, table) CommandResponse Calls a command synchronously, meaning do not continue execution of script until the command completes.
Session callCommandSync(appId, commandId, table, timeoutMillis) CommandResponse Calls a command synchronously with a specified timeout, meaning do not continue execution of script until the command completes.
Session callRpcSync(rpcRequest) RpcResponse Sends a request to a remote instanceof of AMI using CORS.
Session copyToClipboard(text) String Copies text to clipboard - returns result of copy
Session downloadToBrowser(fileName, fileData) Boolean Returns true if able to download file to browser, false otherwise.
Session downloadToBrowser(fileName, fileData) Boolean Returns true if able to download file to browser, false otherwise.
Session exec(when, amiScript) Object Runs script deferred. The provided script is compiled in current thread, but executed outside this call. If provided time is in the past, then the script will be executed at the earliest opportunity. This always runs on the root layout, we recommend using layout.exec(...) instead.
Session exportLayout() Map Exports the current layout to a map.
Session getBrowserIp() String Returns the current browser ip. Takes into account loopback addresses, VPN, and if using AWS
Session getBrowserTitle() String Returns the title shown in the browser title bar.
Session getBrowserZoom() Double Returns the Browser Zoom (1 = 100%)
DashboardResource getCallback(callbackName) Callback Returns a callback by name
DashboardResource getCallbacks() Map Returns a map of all callback definitions.
DashboardResource getChildren() List Returns a list of the child dashboard resources.
Object getClassName() String Returns the string name of this object's class type.
Session getCustomPreference(customPreferenceId) Object Returns a custom prefernce, or null if no custom preference exists for the id.
Session getCustomPreferenceIds() Set Returns a set of the existing custom preferences ids.
DashboardResource getDRI() String Returns the Dashboard Resource Indicator (DRI) as a string. DRI is the unique identifier of this resources within the entire dashboard.
DashboardResource getDashboardResourceType() String Returns the Dashboard Resource Type as a string
Session getDashboardStyleSet() StyleSet Returns the StyleSet for this panel.
Session getDatamodels() List Returns all datamodels.
Session getDesktopLocation() Rectangle Returns the location of the desktop, upper left is always zero, the width and height reflect the browser size (minus window border).
Session getDevTools() DevTools Returns the dev tools for this session, or null if account is a non-dev user.
Session getFileSystem() FileSystem Returns an object for accessing the file system that amiweb is running on.
DashboardResource getFormula(formulaName) Formula Returns a Formula given the formula name.
DashboardResource getFormulaNames() Set Returns a set of the names of all formulas for this object.
DashboardResource getFormulas() Map Returns a map of all available formulas for this object. The key is the formula name.
Session getGlobalProperty(key) String Returns the value associated with key from this servers properties, for example a property set in root.properties file. Returns null if property does not exect
Session getHostIp() String Returns the current host ip of the remote connection known by the ami web server.
DashboardResource getLRI() String Returns the Localized Resource Indicator (LRI) as a string. LRI is the unique identifier of this resource with the parent element.
Session getLabel() String Returns the label associated with this session. The label is visible in the 3forge_session page
Session getLoginId() String Returns the current sessionid.
DashboardResource getOwner() DashboardResource Returns the DashboardResource that owns this object.
Session getPanels() List Returns all AMI panels.
Session getProperty(key) String Returns value associated with key from this sessions global properties. Returns null if key does not exist.
Session getRelationship(relationshipId) Relationship Returns the relationship for the given alias.relationshipId, or null if there is no relationship with the given id.
Session getRelationships() List Returns a list of all relationships.
Session getRootLayout() Layout Returns root layout for this dashboard.
Session getSessionId() String Returns the current sessionid.
Session getSsoSession() SsoSession Returns the sso session associated with this user session.
Session getStyleSet(styleSetId) StyleSet Returns the styleset for a given id.
Session getStyleSetIds() Set Return set of ids for all defined stylesets, including ids for predefined styles.
Session getStyleSets() List Returns a list of all stylesets, including predefined ones.
Session getTimeZone() String Returns the user's timezone Identifier, same as the global reserved variable __TIMEZONE.
Session getTransientIdPrefix() String Returns the transient id prefix
Session getUrl() String Returns the url.
Session getUrlParams() Map Returns all AMI windows as a map of ami alias dot panel id to window.
Session getUserPreferencesNamespace() String Returns the user preferences namespace set on this dashboard.
Session getUsername() String Returns the current username, which is the name used to login.
Session getValue(key) Object Returns the value associated with key from this sessions attributes. Returns null if key does not exist.
Session getValues() Map Returns a map of the values from this sessions attributes. Note, modifying the returned map will have no effect on the sessions variables.
Session getWindows() List Returns all AMI windows as a list.
Session getWindowsMap() Map Returns all AMI windows as a map of ami alias dot panel id to window.
Session importDatamodel(dmConfig) Datamodel Imports a datamodel.
Session importWindow(windowName, panelConfig) Boolean Imports a new Window.
DashboardResource invokeCallback(callbackName, args) Object Executes the specified callback definition and returns the result from the callback.
Session isFeedSnapshotProcessed(type) Boolean Returns true if the snapshot has been processed from ALL centers for the supplied type.
Session isHttpsConnection() Boolean Returns true if the browser is connected over https (instead of http).
DashboardResource isTransient() Boolean Returns true if this is transient, false otherwise. Transient objects are not saved to the layout.
Session loadLayout(layoutName, layoutConfig) Boolean Loads a layout from a json configuration, see exportConfig().
Session loadUserPreferences(userPreferences) String Loads the user preferences.
Session loadUserPreferences() Boolean Loads the user preferences. Same as Account > Load Preferences. Returns false if User Namespace is not set
Session log(message, additionalMessages) String Logs user description followed by dash dash and then a concatenation of supplied arguments to AMISCRIPT logger. Returns message logged.
Session logout() String Ends this users session and logs the user out of all sessions. NOTE: If user is a developer, then follows Account -> My Developer Settings -> On Automated Logout settings.
Session notify(title, body, imageurl, options, attachment) String Displays a notification to the user in the task tray. When the user clicks on the notification the Layout::onNotificationHandled(...) is called. Returns a unique id representing the notification.
Session now() UTC Returns the current time in milliseconds since unix epoch.
Session nowNano() UTCN Returns the current time in nanoseconds since unix epoch.
Session openWindowURL(url, percentSizeOfMainWndow, windowName, customFeatures) Object Opens a new Window with the url, size, name, and custom features specified.
Session playAudio(audiourl) Object Plays audio, specified by the url.
Session prompt(alertText, title, buttons) String Shows a dialog with given text and title, along with a list of buttons to choose from. Return blocks until user chooses a button, returns whichever button was pressed, or null if the user closed the dialog.
Session putCustomPreference(customPreferenceId, PreferencesOrNull) Object Sets the custom preferences by id, if preferencesOrNull is null then existing preferences are removed.
Session saveUserPreferences() Boolean Saves the user preferences. Same as Account > Save Preferences. Returns false if User Namespace is not set
Session sendEmail(fromAddress, toAddresses, subject, isHtml, body, attachmentNames, attachmentDatas, optionalUsername, optionalPassword) String Sends an email and returns immediately with the email-send-UID.
Session sendEmailSync(fromAddress, toAddresses, subject, isHtml, body, attachmentNames, attachmentDatas, optionalUsername, optionalPassword) String Sends an email and returns with the email result.
Session setBrowserTitle(title) Object Sets the title shown in the browser title bar. If supplied title is null or blank, sets back to default.
Session setLabel(label) Object Set the label associated with this session. The label is visible in the 3forge_session page
Session setUrlParams(url_params) Object Rewrite the browser's current URL parameters. Note, the LAYOUT param can NOT be modifed using this method and will be ignored if supplied. Also, this will not cause the onUrlParams callback to be fired
Session setValue(key, value) Boolean Sets the key value pair to this session's attributes and returns true if successful.
Object toJson() String Returns a json representation of this object.
Session warn(message, additionalMessages) String Logs at warning level the user description followed by dash dash and then a concatenation of supplied arguments to AMISCRIPT logger. Returns message logged.

Method Definitions


alert(alertText,closeButtonTextAndTitleText)

String Session::alert(Object alertText, Object ... closeButtonTextAndTitleText)

Description

Shows alert dialog with given text. The second and third arguments are optional. Returns null.

Parameter Definition

Name Type Description
alertText Object  The text content of the alert
closeButtonTextAndTitleText Object ...  the text for the close button. Defaults to "Close". the text for the title (top left). Defaults to "MESSAGE".

callCommand(appId,commandId,table)

String Session::callCommand(String appId, String commandId, Table table)

Description

Calls a command (asynchronously) and returns the command uid. If the command has no route, then null is returned. See callback Layout::onAsyncCommandResponse(...) for processing the response once it's available. WARNING: If multiple commands are registered under the same appId and commandId then it will call the first

Parameter Definition

Name Type Description
appId String 
commandId String 
table Table 

callCommand(appId,commandId,table,timeoutMillis)

String Session::callCommand(String appId, String commandId, Table table, Number timeoutMillis)

Description

Calls a command (asynchronously) and returns the command uid. If the command has no route, then null is returned. See callback Layout::onAsyncCommandResponse(...) for processing the response once it's available.

Parameter Definition

Name Type Description
appId String 
commandId String 
table Table 
timeoutMillis Number 

callCommandSync(appId,commandId,table)

CommandResponse Session::callCommandSync(String appId, String commandId, Table table)

Description

Calls a command synchronously, meaning do not continue execution of script until the command completes.

Parameter Definition

Name Type Description
appId String 
commandId String 
table Table 

callCommandSync(appId,commandId,table,timeoutMillis)

CommandResponse Session::callCommandSync(String appId, String commandId, Table table, Number timeoutMillis)

Description

Calls a command synchronously with a specified timeout, meaning do not continue execution of script until the command completes.

Parameter Definition

Name Type Description
appId String 
commandId String 
table Table 
timeoutMillis Number 

callRpcSync(rpcRequest)

RpcResponse Session::callRpcSync(RpcRequest rpcRequest)

Description

Sends a request to a remote instanceof of AMI using CORS.

Parameter Definition

Name Type Description
rpcRequest RpcRequest 

copyToClipboard(text)

String Session::copyToClipboard(String text)

Description

Copies text to clipboard - returns result of copy

Parameter Definition

Name Type Description
text String 

downloadToBrowser(fileName,fileData)

Boolean Session::downloadToBrowser(String fileName, Binary fileData)

Description

Returns true if able to download file to browser, false otherwise.

Parameter Definition

Name Type Description
fileName String  the name of the file
fileData Binary  the content of the file

downloadToBrowser(fileName,fileData)

Boolean Session::downloadToBrowser(String fileName, String fileData)

Description

Returns true if able to download file to browser, false otherwise.

Parameter Definition

Name Type Description
fileName String  the name of the file
fileData String  the content of the file

exec(when,amiScript)

Object Session::exec(Number when, String amiScript)

Description

Runs script deferred. The provided script is compiled in current thread, but executed outside this call. If provided time is in the past, then the script will be executed at the earliest opportunity. This always runs on the root layout, we recommend using layout.exec(...) instead.

Parameter Definition

Name Type Description
when Number  time - negative number is milliseconds in the future from now, zero or positive number is absolute time in millis.
amiScript String  Script to execute

exportLayout()

Map Session::exportLayout()

Description

Exports the current layout to a map.


getBrowserIp()

String Session::getBrowserIp()

Description

Returns the current browser ip. Takes into account loopback addresses, VPN, and if using AWS


getBrowserTitle()

String Session::getBrowserTitle()

Description

Returns the title shown in the browser title bar.


getBrowserZoom()

Double Session::getBrowserZoom()

Description

Returns the Browser Zoom (1 = 100%)


getCustomPreference(customPreferenceId)

Object Session::getCustomPreference(String customPreferenceId)

Description

Returns a custom prefernce, or null if no custom preference exists for the id.

Parameter Definition

Name Type Description
customPreferenceId String 

getCustomPreferenceIds()

Set Session::getCustomPreferenceIds()

Description

Returns a set of the existing custom preferences ids.


getDashboardStyleSet()

StyleSet Session::getDashboardStyleSet()

Description

Returns the StyleSet for this panel.


getDatamodels()

List Session::getDatamodels()

Description

Returns all datamodels.


getDesktopLocation()

Rectangle Session::getDesktopLocation()

Description

Returns the location of the desktop, upper left is always zero, the width and height reflect the browser size (minus window border).


getDevTools()

DevTools Session::getDevTools()

Description

Returns the dev tools for this session, or null if account is a non-dev user.


getFileSystem()

FileSystem Session::getFileSystem()

Description

Returns an object for accessing the file system that amiweb is running on.


getGlobalProperty(key)

String Session::getGlobalProperty(String key)

Description

Returns the value associated with key from this servers properties, for example a property set in root.properties file. Returns null if property does not exect

Parameter Definition

Name Type Description
key String 

getHostIp()

String Session::getHostIp()

Description

Returns the current host ip of the remote connection known by the ami web server.


getLabel()

String Session::getLabel()

Description

Returns the label associated with this session. The label is visible in the 3forge_session page


getLoginId()

String Session::getLoginId()

Description

Returns the current sessionid.


getPanels()

List Session::getPanels()

Description

Returns all AMI panels.


getProperty(key)

String Session::getProperty(String key)

Description

Returns value associated with key from this sessions global properties. Returns null if key does not exist.

Parameter Definition

Name Type Description
key String 

getRelationship(relationshipId)

Relationship Session::getRelationship(String relationshipId)

Description

Returns the relationship for the given alias.relationshipId, or null if there is no relationship with the given id.

Parameter Definition

Name Type Description
relationshipId String  id of the relationship

getRelationships()

List Session::getRelationships()

Description

Returns a list of all relationships.


getRootLayout()

Layout Session::getRootLayout()

Description

Returns root layout for this dashboard.


getSessionId()

String Session::getSessionId()

Description

Returns the current sessionid.


getSsoSession()

SsoSession Session::getSsoSession()

Description

Returns the sso session associated with this user session.


getStyleSet(styleSetId)

StyleSet Session::getStyleSet(String styleSetId)

Description

Returns the styleset for a given id.

Parameter Definition

Name Type Description
styleSetId String  Id of the styleSet to return

getStyleSetIds()

Set Session::getStyleSetIds()

Description

Return set of ids for all defined stylesets, including ids for predefined styles.


getStyleSets()

List Session::getStyleSets()

Description

Returns a list of all stylesets, including predefined ones.


getTimeZone()

String Session::getTimeZone()

Description

Returns the user's timezone Identifier, same as the global reserved variable __TIMEZONE.


getTransientIdPrefix()

String Session::getTransientIdPrefix()

Description

Returns the transient id prefix


getUrl()

String Session::getUrl()

Description

Returns the url.


getUrlParams()

Map Session::getUrlParams()

Description

Returns all AMI windows as a map of ami alias dot panel id to window.


getUserPreferencesNamespace()

String Session::getUserPreferencesNamespace()

Description

Returns the user preferences namespace set on this dashboard.


getUsername()

String Session::getUsername()

Description

Returns the current username, which is the name used to login.


getValue(key)

Object Session::getValue(String key)

Description

Returns the value associated with key from this sessions attributes. Returns null if key does not exist.

Parameter Definition

Name Type Description
key String 

getValues()

Map Session::getValues()

Description

Returns a map of the values from this sessions attributes. Note, modifying the returned map will have no effect on the sessions variables.


getWindows()

List Session::getWindows()

Description

Returns all AMI windows as a list.


getWindowsMap()

Map Session::getWindowsMap()

Description

Returns all AMI windows as a map of ami alias dot panel id to window.


importDatamodel(dmConfig)

Datamodel Session::importDatamodel(Map dmConfig)

Description

Imports a datamodel.

Parameter Definition

Name Type Description
dmConfig Map 

importWindow(windowName,panelConfig)

Boolean Session::importWindow(String windowName, Map panelConfig)

Description

Imports a new Window.

Parameter Definition

Name Type Description
windowName String 
panelConfig Map 

isFeedSnapshotProcessed(type)

Boolean Session::isFeedSnapshotProcessed(String type)

Description

Returns true if the snapshot has been processed from ALL centers for the supplied type.

Parameter Definition

Name Type Description
type String  type, aka Table name

isHttpsConnection()

Boolean Session::isHttpsConnection()

Description

Returns true if the browser is connected over https (instead of http).


loadLayout(layoutName,layoutConfig)

Boolean Session::loadLayout(String layoutName, Map layoutConfig)

Description

Loads a layout from a json configuration, see exportConfig().

Parameter Definition

Name Type Description
layoutName String 
layoutConfig Map 

loadUserPreferences(userPreferences)

String Session::loadUserPreferences(String userPreferences)

Description

Loads the user preferences.

Parameter Definition

Name Type Description
userPreferences String  user preferences. User preferences format follows the exported user preferences.

loadUserPreferences()

Boolean Session::loadUserPreferences()

Description

Loads the user preferences. Same as Account > Load Preferences. Returns false if User Namespace is not set


log(message,additionalMessages)

String Session::log(Object message, Object ... additionalMessages)

Description

Logs user description followed by dash dash and then a concatenation of supplied arguments to AMISCRIPT logger. Returns message logged.

Parameter Definition

Name Type Description
message Object 
additionalMessages Object ... 

logout()

String Session::logout()

Description

Ends this users session and logs the user out of all sessions. NOTE: If user is a developer, then follows Account -> My Developer Settings -> On Automated Logout settings.


notify(title,body,imageurl,options,attachment)

String Session::notify(String title, String body, String imageurl, Map options, Map attachment)

Description

Displays a notification to the user in the task tray. When the user clicks on the notification the Layout::onNotificationHandled(...) is called. Returns a unique id representing the notification.

Parameter Definition

Name Type Description
title String  title of the notification
body String  html body of the notification
imageurl String  the url of the image (icon)
options Map 
attachment Map  an attachment to be included in the callback (passed into 3rd param of Layout::onNotificationHandled)

now()

UTC Session::now()

Description

Returns the current time in milliseconds since unix epoch.


nowNano()

UTCN Session::nowNano()

Description

Returns the current time in nanoseconds since unix epoch.


openWindowURL(url,percentSizeOfMainWndow,windowName,customFeatures)

Object Session::openWindowURL(String url, Double percentSizeOfMainWndow, String windowName, String customFeatures)

Description

Opens a new Window with the url, size, name, and custom features specified.

Parameter Definition

Name Type Description
url String  required url of target window
percentSizeOfMainWndow Double  optional percentSizeOfWindow - valid values are 0.1 - 1.0, null creates new tab
windowName String  optional name of window, _blank by default
customFeatures String  optional windowFeatures - see javascript window.open

playAudio(audiourl)

Object Session::playAudio(String audiourl)

Description

Plays audio, specified by the url.

Parameter Definition

Name Type Description
audiourl String  the url of the audio clip to play

prompt(alertText,title,buttons)

String Session::prompt(Object alertText, String title, List ... buttons)

Description

Shows a dialog with given text and title, along with a list of buttons to choose from. Return blocks until user chooses a button, returns whichever button was pressed, or null if the user closed the dialog.

Parameter Definition

Name Type Description
alertText Object 
title String 
buttons List ... 

putCustomPreference(customPreferenceId,PreferencesOrNull)

Object Session::putCustomPreference(String customPreferenceId, Object PreferencesOrNull)

Description

Sets the custom preferences by id, if preferencesOrNull is null then existing preferences are removed.

Parameter Definition

Name Type Description
customPreferenceId String 
PreferencesOrNull Object 

saveUserPreferences()

Boolean Session::saveUserPreferences()

Description

Saves the user preferences. Same as Account > Save Preferences. Returns false if User Namespace is not set


sendEmail(fromAddress,toAddresses,subject,isHtml,body,attachmentNames,attachmentDatas,optionalUsername,optionalPassword)

String Session::sendEmail(String fromAddress, List toAddresses, String subject, Boolean isHtml, String body, List attachmentNames, List attachmentDatas, String optionalUsername, String optionalPassword)

Description

Sends an email and returns immediately with the email-send-UID.

Parameter Definition

Name Type Description
fromAddress String  From Address
toAddresses List  List addresses to send email to
subject String  Email Subject
isHtml Boolean  true=email,false=text
body String  Body
attachmentNames List  Optional List of Attachment Names
attachmentDatas List  Optional List of Attachment data, either Bytes or Strings
optionalUsername String  Optional username to connect to smtp server with
optionalPassword String  Optional password to connect o smtp server with

sendEmailSync(fromAddress,toAddresses,subject,isHtml,body,attachmentNames,attachmentDatas,optionalUsername,optionalPassword)

String Session::sendEmailSync(String fromAddress, List toAddresses, String subject, Boolean isHtml, String body, List attachmentNames, List attachmentDatas, String optionalUsername, String optionalPassword)

Description

Sends an email and returns with the email result.

Parameter Definition

Name Type Description
fromAddress String  From Address
toAddresses List  List addresses to send email to
subject String  Email Subject
isHtml Boolean  true=email,false=text
body String  Body
attachmentNames List  Optional List of Attachment Names
attachmentDatas List  Optional List of Attachment data, either Bytes or Strings
optionalUsername String  Optional username to connect to smtp server with
optionalPassword String  Optional password to connect o smtp server with

setBrowserTitle(title)

Object Session::setBrowserTitle(String title)

Description

Sets the title shown in the browser title bar. If supplied title is null or blank, sets back to default.

Parameter Definition

Name Type Description
title String 

setLabel(label)

Object Session::setLabel(String label)

Description

Set the label associated with this session. The label is visible in the 3forge_session page

Parameter Definition

Name Type Description
label String  label for this session

setUrlParams(url_params)

Object Session::setUrlParams(Map url_params)

Description

Rewrite the browser's current URL parameters. Note, the LAYOUT param can NOT be modifed using this method and will be ignored if supplied. Also, this will not cause the onUrlParams callback to be fired

Parameter Definition

Name Type Description
url_params Map  Url Parameters

setValue(key,value)

Boolean Session::setValue(String key, Object value)

Description

Sets the key value pair to this session's attributes and returns true if successful.

Parameter Definition

Name Type Description
key String 
value Object 

warn(message,additionalMessages)

String Session::warn(Object message, Object ... additionalMessages)

Description

Logs at warning level the user description followed by dash dash and then a concatenation of supplied arguments to AMISCRIPT logger. Returns message logged.

Parameter Definition

Name Type Description
message Object 
additionalMessages Object ...