Start a conversation

The Notification Service

Summary

The Notification Service

Question/Problem Description

This article describes the notification service in update.CRM web.

Environment

update.CRM web 8.x

Resolution

The notification service provides means to display notifications to users.

Depending on the severity and the configuration, notifications may be shown in a different way

  • as a message box vs. only in the inbox.
  • automatically disappearing (after a configurable duration) vs. to be manually closed by the user.
  • ...

The idea behind the notification service is, to let you - as a developer - write your notification to a centralized service without worrying where and how to display them. And - at the same time - allow administrators to configure the way messages should be displayed throughout the application.


The notification service is available as

u8.services.notification

Writing Notifications

The main method to write a notification is  write(o) , where  o  is of type  u8.Base.Notification.Message .

Shortcut Methods

For your convenience there are shortcut methods for the most often used severity levels:

  • Information(severity=300): info( text, show, duration, subject )
  • Notice(severity=250): notice( text, show, duration, subject )
  • Warning(severity=200): warn( text, show, duration, subject )
  • Error(severity=100): error( text, show, duration, subject )
// a warning!
u8.services.notification.warn("A word of warning!");

Notification Targets

Notification targets are responsible for displaying/storing the notification messages. The notification service holds a list of registered targets.

The following targets are available out of the box:

Name Description
NotificationBar Displays the notification as a message box in the lower left corner next to the inbox icon.
This is the default facility.
MessageBox Displays the notification as a modal, centered message box.

If the option  u8.Base.Notification.Message.target  is set, the notification service tries to use this target. Otherwise it tries to use the default target.

If the target has not been registered yet, the notification will be queued until a target with the given name is registered.

Custom Targets

To create a new notification target the following steps are necessary:

Step 1 - Implement the Target

Facilities are simple JavaScript classes that implement the following contract:

function MyNotificationTarget()
{
    // ctor
}
 
MyNotificationTarget.prototype.write = function(o) {
    // o is of type "u8.Base.Notification.Message"
    // insert code to display the notification here.....
}

Step 2 - Register the Target

To register the notification target you have to call method  u8.Base.Notification.addTarget .

u8.services.notification.addTarget("MyTarget", new MyNotificationTarget());

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Priyanka Bhotika

  2. Posted

Comments