- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2024 05:20 PM
Hello experts,
Seeking your advice on all the possible methods to display message on the forms. We know that you can display message using client script and business rules to display message but is there any way other way to do it?
I know that you can't display a message via ACL restriction, but that is correct right? For example a user is restricted via ACL, it is not possible to display a message using only ACL right?
Are there other methods?
Regards,
Vaine
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2024 06:09 PM
Hello @Rain Vaine
There are several ways to display messages on forms in ServiceNow:
- Client Scripts: Use g_form.addInfoMessage(), g_form.addErrorMessage(), or g_form.addWarningMessage().
- Business Rules: Use gs.addInfoMessage() for server-side messages on form reloads.
- UI Policies: Show or hide fields with messages dynamically.
- Annotations: Add static messages directly on forms.
- UI Actions: Display messages when a button is clicked.
- Modal Dialogs: Use GlideModal for interactive messages.
- Read-Only Fields: Populate dynamic messages in read-only fields using scripts.
- Widgets: For Service Portal forms, use custom widgets to show messages.
Note: ACLs alone cannot display messages but can be combined with Business Rules or Client Scripts to show alerts before enforcing restrictions.
"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2024 06:09 PM
Hello @Rain Vaine
There are several ways to display messages on forms in ServiceNow:
- Client Scripts: Use g_form.addInfoMessage(), g_form.addErrorMessage(), or g_form.addWarningMessage().
- Business Rules: Use gs.addInfoMessage() for server-side messages on form reloads.
- UI Policies: Show or hide fields with messages dynamically.
- Annotations: Add static messages directly on forms.
- UI Actions: Display messages when a button is clicked.
- Modal Dialogs: Use GlideModal for interactive messages.
- Read-Only Fields: Populate dynamic messages in read-only fields using scripts.
- Widgets: For Service Portal forms, use custom widgets to show messages.
Note: ACLs alone cannot display messages but can be combined with Business Rules or Client Scripts to show alerts before enforcing restrictions.
"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 04:43 PM
Is it possible for you to give a simple sample implementation on method 4 to 8?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 12:50 AM
Hello @Rain Vaine
Here’s a simple breakdown and sample implementation for methods 4 to 8 to display messages on forms in ServiceNow:
4. Annotations are static messages added directly to the form layout.
Steps:
Navigate to the form layout (e.g., Incident form)
In the Form Layout, drag the Annotation field into the desired section
Double-click to add a message (e.g., “Please ensure all mandatory fields are filled before submission.”)
- Refer to the servicenow documentation: Annotations
Note:This displays static, instructional content on the form without needing scripting.
5. UI Actions: Display messages when a button is clicked.
Setup:
Create a new UI Action on your table (e.g., incident)
Set Client to true, and add the script in the "OnClick" field
Note: Message appears when the button is clicked by the user.
6. Modal Dialogs: Used for displaying messages in a popup dialog.
Refer to the servicenow documentation: Glide Modal
7. Read-Only Fields: Populate dynamic messages in read-only fields using scripts.
Steps:
Add a String field (e.g., form_note) to your form
Set it to Read-Only using dictionary or UI Policy
Populate it via script:
Note: Message updates based on form logic and remains non-editable.
8. Widgets: For Service Portal forms, use custom widgets to show messages.
Example:
<div class="alert alert-warning">
Please verify all fields before submission.
</div>
Widget-based messages are flexible, styled, and dynamic. These widgets can be added to catalog items or record producers in the Service Portal to display important alerts, instructions, or status messages in a user-friendly way.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar