top of page

Experiencing challenges with ServiceNow support?

IKC provides professional, reliable assistance that covers gaps not supported by ServiceNow

and without the high costs of traditional services.

 

Starting from just $1,080 per month

Using Modal Windows in ServiceNow UI Actions



ServiceNow's Agent Workspace provides a streamlined and efficient interface for agents. A common requirement for developers is to trigger modal windows from UI Actions within this workspace to gather additional information or display custom components. This article explores how to effectively use modal windows in Agent Workspace UI Actions, addressing common challenges and providing solutions for a smoother user experience. This is particularly relevant for ServiceNow developers and administrators looking to extend the functionality of Agent Workspace and create more interactive workflows.


One powerful way to enhance the agent experience in ServiceNow Agent Workspace is by using modal windows triggered from UI Actions. These modals can display custom components or standard ServiceNow forms, allowing agents to interact with additional information or provide input without navigating away from their current task.


Understanding the Initial Challenge


A common scenario involves opening a custom component within a modal window using the g_modal API from a UI Action. While the basic implementation for this is documented by ServiceNow, developers often encounter challenges when trying to exert more control over the modal's behavior. This includes:

  • Customizing Modal Buttons: The standard modal might not always offer the desired button options or labels. Developers might want to add specific action buttons relevant to their custom component.

  • Passing Data Back to the Form: After interacting with the custom component in the modal, there's often a need to pass selected data back to the originating ServiceNow form.

  • Controlling the Modal from the Custom Component: In some cases, the logic within the custom component might need to programmatically control the modal, such as closing it based on certain user actions.


Verified Troubleshooting Solutions


While direct control over standard modal buttons and closing mechanisms from a custom component invoked via g_modal.global.showTemplate might be limited, here are some verified approaches and considerations:


  1. Passing Data to the Custom Component: The initial post correctly identifies that you can pass data to your custom component using the params object when calling g_modal.global.showTemplate. This allows you to send information like the current g_form object, table name, or sys_id to your component.

    JavaScript



  1. Using g_modal.showFields for Data Input: For scenarios where you need to collect specific data from the user in a modal, the g_modal.showFields method offers more control over the input fields and button labels. This method allows you to define an array of fields (like text areas, reference fields, or choice lists) to be displayed in the modal.

  2. JavaScript



  1. Leveraging Custom Components for Advanced Control: For more intricate control over the modal's UI and behavior, including custom buttons and data handling, the recommended approach often involves building a dedicated custom component. While the initial post explored using g_modal.global.showTemplate with a custom component, the limitations in directly manipulating the standard modal buttons were noted.


Practical Examples and Use Cases


  • Displaying a Confirmation Modal: You could use g_modal.showFields with a simple text field to display a confirmation message and provide "Confirm" and "Cancel" buttons.

  • Gathering Additional Information: When a specific UI Action is triggered, a modal can appear with fields to collect extra details related to the current record.

  • Presenting a Selection List: A custom component displayed in a modal can present a list of options (like categories, as mentioned in the original post), allowing the user to select one or more items. The selected values can then be passed back to the form using the params object and potentially an event mechanism within the custom component.


Alternative Solutions


While g_modal is a primary way to display modals in Agent Workspace, consider these alternative approaches depending on your specific needs:

  • Client Scripts: For simpler interactions or validations, client scripts can sometimes be used to display alerts or confirmations without needing a full modal window.

  • UI Builder: For more complex custom interfaces within Agent Workspace, exploring the capabilities of UI Builder might offer more flexibility in designing interactive components.


Conclusion


Using modal windows effectively in ServiceNow Agent Workspace UI Actions can significantly enhance the user experience by providing focused interactions and streamlined workflows. While direct manipulation of standard g_modal buttons might be challenging when using custom components, leveraging the params object for data passing and considering g_modal.showFields for data input are valuable techniques. For more advanced control over modal UI and behavior, building dedicated custom components and exploring alternative ServiceNow development tools like UI Builder might be necessary. The key takeaway is to understand the specific requirements of your use case and choose the most appropriate method to create intuitive and efficient interactions within the Agent Workspace. ServiceNow developers should explore the capabilities of custom components and the various g_modal methods to create tailored modal experiences.

Experiencing challenges with ServiceNow support?

IKC provides professional, reliable assistance that covers gaps not supported by ServiceNow

and without the high costs of traditional services.

 

Starting from just $1,080 per month

CONTACT

New Zealand HQ

Integrated Knowledge Consulting Office

Level 3, 93 Grafton Road

Auckland

South Korea

Integrated Knowledge Consulting Office

BMY역삼타워 6층

서울특별시 강남구 역삼동 678-10번지

 

info@ikconsulting.com

Thanks for submitting!

  • LinkedIn Social Icon

© Copyright 2025 Integrated Knowledge Consulting. All rights reserved.

bottom of page