Skip to content

NEW 2022/11/30

Warning

This applies to Detail Views, only!

Conditional Notifications

Detail View provides functions for conditionally showing custom notifications at the top of the page. This allows you to define conditions, which will be evaluated on load and on every change. Depending on the result of this evaluation, the notification will be shown or hidden.

  • Define a function which returns boolean (true | false).
  • If it returns true, the notification be shown.
  • If the function return false, the notification will be hidden.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// file: hooks/tasks-dv.js
var notifications = dv.getNotifications();
var alert = notifications.add("EXTERNAL delivery but Recipient is missing", Variation.danger);

alert.setFunction(function() {

    // show danger-alert if this is an external delivery without recipient
    var type_code = dv.getField("type_code").getValue();
    var recipient_id = dv.getField("recipient_id").getValue();

    // if this is EXTERNAL and recipient IS NULL, return true to SHOW the notification
    // otherwise return false to HIDE the notification
    return type_code == "TRANSFER_EXTERNAL" && recipient_id == null;

});

// render (all) notifications
dv.getNotifications().show();

Note

Conditional Notifications will never have a close-button x nor will they be autoclosed after n seconds, because visibility will be controlled by your function, not by user-interaction.

Example

See also