NexJ Logo

Configuring alarms

Alarms allow users to manage reminders for tasks and schedule items. These reminders trigger notifications that appear to the users at a specified time. If the users is logged on to NexJ CRM at the time set for the reminder, then a notification dialog opens and shows the task or schedule item's information. The dialog also displays reminders for any other activities that have not been cleared, such as reminders that occurred when the user was not logged on.

You can configure alarms through the following series of steps:

  1. Create a dialog that uses the Alarms control to display a list of reminders for activities.
  2. Configure the application to receive a push notification to display the dialog.
  3. Configure the model metadata to trigger the push notification that shows the alarm.

Creating a dialog that uses the Alarms control to display a list of reminders for activities

You can use the following example, taken from AlarmNotification.dialog, as a model for your own implementation. Additional details can be found in the dialog file.

Example: AlarmNotifications.dialog
<Dialog caption="idss.AlarmNotifications.reminders">
   <UIActions>
      <UIAction event="alarmClear">
      <UIAction event="alarmClearAll">
      <UIAction event="alarmSnooze">
      <UIAction event="sysClose">
      <UIAction event="markCompleted">
   </UIActions>
   <Composite name="tblRootLayout">
      <LayoutRef head="true" layout="mda:AlarmList" name="dueAlarmList" where="... (<= alarmTime (cast timestamp (+ (cast long (now)) (SysNotification'getExpiration)))) (= (@ entity) (user-person)))"/>
   </Composite>
   <Actions layout="mda:AlarmButtons" name="frmAlarmButtons"/>
</Dialog>
  • The alarmClear, alarmClearAll, alarmSnooze, sysClose, and markCompleted actions are supported by the Alarms control. These UI event handlers must be defined in the dialog to invoke appropriate model event.
  • The example includes a layoutRef, which references a layout containing the Alarms control. The where clause within the reference returns all reminders "between now and a future time limit (configurable in the model) that belong to this user."

See Alarms for details of configuring this control in a layout and details of the UI events.

Configuring the application to receive a push notification to display the dialog

The example below configures a push notification receiver for the ContactBroker portlet to receive notifications with the "pastAlarmsAFL" key. When the portlet receives a push notification with this key from the server, the mda:AlarmNotifications dialog opens. It's important to configure this in a top-level portlet, such as ContactBroker, which is always loaded with the application to initialize the push notification receiver.

You can configure periodic polling of reminders by using the time property. In this example, the time property is set to alarmTime, an attribute of UserParticipation which is the class bind for the alarms dialog. Setting this property automatically schedules the alarm dialog to open at the appropriate time or removes a scheduled reminder if an event changes.

This example is taken from ContactBroker.portlet.

Example: Configuring notification metadata in a portlet
   <Notifications>
      <Notification dialog="mda:AlarmNotifications" key="pastAlarmsAFL" time="alarmTime" view="dueAlarmList"/>
   </Notifications>

Configuring model metadata to trigger the push notification to show the alarm

Whenever you create an activity with a reminder, you need to configure the model to send a push notification to the user's client to tell it to open a reminder dialog.

The following example is taken from UserParticipation.meta. In this example, the class bind for the Alarm dialog is UserParcipation, which (again, in this example) is configured to send a push notification whenever a "commit" or "delete" event occurs. Whenever there is a change in a UserParticipation instance the client receives a push notification containing the notification metadata configured above. It then opens a reminder dialog based on the alarmTime value of the UserParticipation instance, or removes a scheduled reminder.

In the server, the push notification is sent to the client for a specific key by invoking (SysNotification'changeSet "pastAlarmsAFL" (@ entity user)).

Example: Sending a push notification from the server
<Event name="commit">
    <Action name="resetAlarmsCache" type="before">[CDATA[
		(SysNotification'changeSet "pastAlarmsAFL" (@ entity user))
]]</Action>
</Event>
<Event name="delete">
    <Action name="resetAlarmsCache" type="before">[CDATA[
		(SysNotification'changeSet "pastAlarmsAFL" (@ entity user))
]]</Action>
</Event>

Disabling alarms during development

To disable alarms, for example for automated testing, you can run the following JavaScript in a 9.2 application:
var mda=define.find('nexj/ui/mda');if(mda)mda.Context.get().alerting(false);

Related information

MDA Controls - Alarm