- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2023 09:00 AM
Hi All ,
Can someone help me disable autohide the popup messages in the ServiceNow Service Catalog Form?
Please take a look at the screenshot for reference.
I want this message to display stable "Please allow up to 10 business days to review contracts that are not auto-generated."
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2023 09:50 AM
@NagaNandini N : As you are setting the message via client side API, please refer the below article that describes all methods in details.
http://servicenowguru.com/scripting/ui-info-error-message-cheat-sheet/
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2023 04:45 AM
@NagaNandini N : please follow the below HI Article that explains the implementation.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0713722
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2023 09:50 AM
@NagaNandini N : As you are setting the message via client side API, please refer the below article that describes all methods in details.
http://servicenowguru.com/scripting/ui-info-error-message-cheat-sheet/
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2023 09:55 AM
Reading your title and your post it seems like they ask the opposite. The title asks how to hide the messages, but in the post it sounds like you are actually looking for how to disable the hiding of the message?
Anyways for hiding the messages: since you are using g_form i assume you are having this in a clientside script. The gs.flushMessages() method works for serverside script, so instead use the following:
GlideUI.get().clearOutputMessages(); - Hides ALL info/error messages on the page
If you want more specific control over what to hide:
g_form.hideFieldMsg("fieldname", clearAll(optional)) - Insert a field name to apply the hiding on. if you set clearAll to true it will hide all message, if you leave it empty it will only delete the last message.
g_form.hideAllFieldMsgs(type(optional)) Hides ALL field info and error messages. You can provide "info" or "error" as a parameter to hide only that specific type of messages.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2023 12:47 PM - edited 12-25-2023 12:50 PM
Hi,
After some experimenting the best way seems to be manipulating the css container of the actual message. Unfortunately there is no way to turn the autohiding on or off already with existing functions. But below workaround will help out and will leave the message visible until closed by the 'X':
function onLoad() {
g_form.addInfoMessage("Testmessage");
// Select the notification container
var notificationContainer = top.document.getElementById('uiNotificationContainer');
if (notificationContainer) {
// Create an observer to monitor DOM changes
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach(function(node) {
if (node.nodeName === 'DIV' && node.classList.contains('notification')) {
// Stop any animations or auto-hide features
node.style.animation = 'none';
}
});
});
});
// Start observing
observer.observe(notificationContainer, { childList: true });
}
}