H

ere’s a quick scripting tip for today. Have you ever needed to refresh the left navigation menu in response to some script action? I don’t think this requirement comes up often, but I just had somebody ask me a question related to this so I figured I would find out how it can be done.


The code below is taken directly from a ServiceNow demo instance, and you can find it in your own instance as well. The server-side example comes from a business rule on the ‘sys_app_module’ table, and the client-side example comes from digging around in the DOM. 🙂

Server-side refresh trigger

–For use in business rules, UI actions, etc.

// tell the UI to refresh the navigator
var notification = new UINotification('system_event');
notification.setAttribute('event', 'refresh_nav');
notification.send();

Client-side refresh trigger

–For use in client scripts, UI policies, etc.

getNavWindow().location = 'navigator_change.do';

 

For another way to use UI Notifications, take a look at our article Display Messages With UI Notifications.