GlideAgentWorkspace (g_aw) - Client
-
- UpdatedJan 30, 2025
- 8 minutes to read
- Yokohama
- API reference
The g_aw API provides methods that enable a UI action or client script to open a specified record in an Agent Workspace tab.
There is no constructor for this class. Access GlideAgentWorkspace methods using the g_aw
global object.
GlideAgentWorkspace - closeRecord()
Closes the currently open record, such as a form, in a subtab within Agent Workspace.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
None |
Example
function onClick(g_form) {
Example
g_aw.closeRecord()
method to close a record when a button is clicked in Agent Workspace. You can use this script as follows:- Add this script to a UI Action (button) configured for Agent Workspace.
- When the button is clicked, it will attempt to close the current record.
- Basic logging indicates success or failure.
Example
- Trigger Condition: The script checks if the incident's state is set to "Resolved" (
state = 6
). - Workspace Validation: Ensures the code runs only within Agent Workspace using
typeof g_aw !== 'undefined'
. - Promise Handling: Uses .then() and .catch() for handling the asynchronous nature of closeRecord().
- Error Handling: Provides detailed logging for both successful and failed attempts.
GlideAgentWorkspace - openRecord(String table, String sysId, Object params)
Opens a specified record, such as a form, in a subtab within Agent Workspace.
Type | Description |
---|---|
None |
Example
Open a sys_user record in a subtab.
Example
Open a record in a subtab where all fields are read-only.
Example
Open a record in a subtab and go directly to the "Groups" related list.
Example
Open a record in a subtab but only show the form header and other tabs.
Example
- Dynamic Record Opening: The script retrieves the sys_id of the related change request from the current incident.
- Agent Workspace Context: It checks if
g_aw
is available to confirm the script is running in Agent Workspace. - Custom Parameters:
view: 'agent'
opens the record in a specific view (optional).readOnly: true
opens the record in read-only mode (optional).
- Error Handling: Uses .then() and .catch() for handling responses and errors.
GlideAgentWorkspace - setSectionExpanded(String section_name, Boolean expanded)
Sets a form section to expanded or collapsed state.
For a use case, see Change the default form section navigation in legacy workspace.
Name | Type | Description |
---|---|---|
section_name | String | Name of a form section in Agent Workspace. |
expanded | Boolean | Flag that indicates whether a section is to be expanded or collapsed by default.
|
Type | Description |
---|---|
None |
Example
The following example shows how to set a form section named related_records
to collapse by default.
Example
- Priority-Based Logic: The script checks the incident's priority using
g_form.getValue('priority')
. - Dynamic Section Control: Expands the "Work Notes" section if the priority is 1 (Critical) or 2 (High). Collapses it for lower priorities to maintain a cleaner UI.
- Agent Workspace Check: Ensures the script only runs in Agent Workspace.
GlideAgentWorkspace - domainScopeProvider()
Gets the domain scope details.
The domainScopeProvider() method accesses four functions to return information about the domain scope. For information, see Domain scope.
Required role – domain_expand_scope.
Type | Description |
---|---|
None |
Example: Example
The following example shows how to toggle the domain scope between the user session and the record as expanded (session scope) or collapsed (record scope) in a UI action workplace client script.
Example
Example
- Basic Checks:
typeof g_aw !=='undefined'
ensures the script only runs in Agent Workspace.g_aw.domainScopeProvider
checks if the method exists. - Simple Asynchronous Handling: Uses
.then()
to process the result when the domain info is available. Uses.catch()
to handle any errors (for example, if something goes wrong when fetching the domain). - User-Friendly Alert: Displays an alert with the domain name (
alert('You are working in the domain: ...')
), which is simple and easy to understand. If no domain info is found, it alerts the user with "Domain information is not available.
" - Error Handling: Errors are logged to the console using
console.error()
for basic troubleshooting.
You can add this script as an "onLoad" Client Script in Agent Workspace. When an agent opens a record, an alert will pop up showing the current domain name.