logo

NJP

Why addInfoMessage / addErrorMessage Don't Work in Custom Workspaces – and How to Fix It

New article articles in ServiceNow Community · May 02, 2025 · article

Standard server-side messages like addInfoMessage or addErrorMessage do not automatically appear in custom Workspaces. This article provides a simple fix using UI Builder to manually map the notification behavior.

Problem:

When working with custom ServiceNow Workspaces, the traditional server-side messaging methods like addInfoMessage() or addErrorMessage() do not display messages to users as they do in the classic UI.

Root Cause:

Custom pages built with UI Builder do not automatically include logic to render these notifications. Instead, notifications must be explicitly handled through the component event mappings.


Solution (Step-by-Step):

  1. Open UI Builder
    Navigate to the UI Builder and select the page where you want the notification to appear.
  2. Select the Trigger Component
    Identify the component responsible for triggering the message (e.g., a list or a button). In my use case, it was a button inside a List component.
    sarah_bioni_3-1746200869209.png
  3. Go to the "Events" Tab
    With the component selected, open the Events tab on the right-hand panel.
    sarah_bioni_4-1746200894374.png
  4. Add an Event Mapping
    Click on "Add event mapping".
    • Name: Notification(s) displayed
    • Action: Add alert notifications
    • Items parameter: {{event.payload.notifications}}
      This tells the component to listen for notification payloads and render them as alert banners.
      sarah_bioni_5-1746200925428.pngsarah_bioni_6-1746200932087.png
  5. Test the Notification
    After this configuration, when your server script (e.g., in a UI Action or Script Include) calls addInfoMessage() or addErrorMessage(), the messages will be properly passed through and rendered by the UI component.
View original source

https://www.servicenow.com/community/next-experience-articles/why-addinfomessage-adderrormessage-don-t-work-in-custom/ta-p/3253359