Service Portal: How to send focus to a field after spUtil.addErrorMessage is dismissed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 11:10 AM
We are trying to achieve the same Service Portal behavior as the out of box catalog item widget interacting with the spUtil.addErrorMessage notification banner message to satisfy an accessibility issue on a custom widget we have created.
This is the OOB behavior we are trying to mimic:
- When a user with the Accessibility user preference enabled attempts to submit a catalog item that still has mandatory fields that need to be filled in, a notification error message is displayed at the top of the screen detailing the fields that need to be filled out, and the focus goes to the 'X' button on that notification message.
- When the user dismisses the notification message using the 'Enter' key on their keyboard, the focus then goes to the first mandatory field on the catalog item being filled out.
The issue on our custom widget is, we do not know how to determine when that notification message is dismissed since the notification message functionality is behind the scenes ServiceNow code. We suspect the code for this might be handled in the "https://<sinstance_name>/scripts/js_includes_sp.jsx" JS include, but we do not know how to determine when the notification message is dismissed from our custom widget.
Essentially, in our custom widget client controller, we need to know how to programmatically send focus to our first mandatory field only when the notification message is dismissed.
Anyone have any idea if this is achievable?