Error Message Expand/Collapsed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
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
Wednesday - last edited Wednesday
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
Wednesday
I don't think you can manipulate that X
may be check the workspace theme if somewhere it's configured.
💡 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
