Adds notification for one or all users.
optional notification title
optional icon, can be in one of three formats:
- URL: "https://website.com/images/image.png" or "images/file.gif"
- Bootstrap icon: "glyphicon-film", "glyphicon-hand-right"
- Font Awesome icon: "fa-envelope", "fa-user"
optional URL. When specified, a click on notification sends the user to the specified address. See makePageLink function
optional expiration date and time for the message. Can be either datetime in "YYYY-MM-DD hh:mm:ss" format, or a number of minutes the notification should be visible.
"2022-01-10 00:00:00" or 1440 for 24-hour period
Optional, null by default. Can be one of the following:
- not specified or null - all users will see this notification
- string i.e. "admin". The value is interpreted as a username. Only the specified user will see the notification.
- array with keys "user" and optional value "provider"
$permissions["user"] - username. Only this user will see the notification.
$permissions["provider"] - when the user is a database user, whose username and password are stored in a database table, this parameter must be empty. When the user is logged via from Active Directory, OpenID, Google etc, then put the two-letter security provider code here. You can find it on the 'Security screen' under the provider settings dialog.
- array with key "group"
$permissions["group"] - only members of this group will see the notification
- array with keys "table" and "page"
$permissions["table"] - name of the table, custom view, report or chart name.
$permissions["page"] - page name like "list", "list1" etc.
When this type of permissions is specified, only those users who have access to the specified page will see the notification.
Optional, false by default. When true, the notification link will be open in a new browser tab. When false, the link will be open in the same browser tab.
No return value
This example shows how to add a notification for all users when a new record added to the Categories table. This code needs to be added to AfterAdd event of the Categories table.
Add notification with with link opened in new window.
Add notification visible only to 'bob' user.
Add notification visible only to 'Administrator' user from Active Directory
Add notification visible only to users who have access to Orders - Edit page
Add notification visible only to users in specific group.