Error Message Expand/Collapsed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
I want to understand the feasibility to expand/collapse the error message created by g_form.addErrorMessage() method on configurable workspace.
1. I want to disable the "X" mark (dismiss alert) icon for users, such that the error message will be open all the time.
2. Next, in PDI the "Show More" is getting expanded by default if the message content is more. However, in customer instance it's not expanding by default. I want to know if we can completely make this error message expanded and not giving an option to collapse by end user.
Please let me know your suggestions and feel free to reply for any additional information.
Regards,
Vasanth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @Vasanth001 ,
Please use the below script. I have implemented this logic in an onLoad Client Script in Native View, and it is working as expected.
This script hides the dismiss (X) icon for the error message added using g_form.addErrorMessage(), ensuring the message remains visible to the user.
⚠️ Important: Please make sure to uncheck the “Isolate script” checkbox in the Client Script.
function onLoad() {
g_form.addErrorMessage(
'This is a very long error message that should remain visible and not be dismissible by the user.'
);
// Delay to ensure message is rendered
setTimeout(function () {
var container = document.getElementById('output_messages');
if (!container) return;
var buttons = container.getElementsByTagName('button');
for (var i = 0; i < buttons.length; i++) {
buttons[i].style.display = 'none';
}
}, 100);
}
Please check the attached screenshot — it is working fine on my end.
Thanks, and regards,
Siddhesh Jadhav
Mark this as Accepted and Helpful if this solves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Thank you for your response however, ServiceNow is not encouraging to use DOM manipulations right! And it should work on Configurable Workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
correct. DOM is not recommended and DOM won't run in workspace
@Siddhesh Jadhav the question is for workspace and not native.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Thank you for marking my response as helpful.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
