-
Notifications
You must be signed in to change notification settings - Fork 9
Documentation
Paul Nieuwelaar edited this page Dec 13, 2021
·
3 revisions
- Download and install the unmanaged solution (recommended), or download the source files from other downloads, and create the required web resources manually using your own publisher prefix and naming style (not recommended as there are hardcoded references in the files).
- Make sure to publish all customizations if installing the unmanaged solution, or creating the web resources manually.
- Create a new JavaScript web resource or use an existing web resource to create your custom functions which will call the notify.js functions.
- Add a reference to the notify.js web resource on your form or view (the other required files are loaded automatically).
- For forms, this is simply added through the form properties.
- For views, add a "JavaScript Function Action" to the "Command Actions" for your button command, calling the notify.js web resource, where the function is "isNaN" (without quotes). Using the Ribbon Workbench to edit the command is recommended.
- Add a reference to your custom JavaScript web resource where you're making the calls to notify.js. This should be added after the reference to notify.js.
- Call your custom function from your JavaScript library, e.g. from the command bar button, or from the form onload event.
Use this method to add or update a notification in the custom notification bar on a form or view. If the unique ID matches an existing notification, that notification will be updated, otherwise a new notification will slide down nicely from the top.
Notify.add(message, level, uniqueId, buttons, durationSeconds, bgColor, textColor);
message
- Type: String. The text of the message.
"Processing, please wait..."
level
-
Type: String. The level of the message. The level defines which icon will be displayed beside the message.
-
ERROR:
Notification will display an error icon.
-
WARNING:
Notification will display a warning icon.
-
INFO:
Notification will display an info icon.
-
SUCCESS:
Notification will display a green tick (success) icon.
-
QUESTION:
Notification will display a question mark icon.
-
LOADING:
Notification will display a CRM loading spinner.
-
ERROR:
"LOADING"
uniqueId
- Type: String. A unique identifier for the message used with Notify.remove to remove the notification, and to allow you to update the same notification without it sliding down again.
"sale"
buttons
- Type: Array of Objects. Optionally, specify one or more buttons or hyperlinks to display beside the message. This can be a useful way of displaying a link to another record or system in an unobtrusive way. The buttons/links will be added to the immediate right of the message text, and will display in the order that you add them.
[
{ type: "button", text: "Create Sale", callback: createSaleFunction },
{ type: "link", text: "Not now", callback: function () { Notify.remove("sale"); } }
]
- Each button Object should contain the following properties:
- type (String): The type of button, must be either "button", or "link". If not specified, this will default to "button".
- text (String): The text to display on the button, or as the hyperlink text.
- callback (function): A custom function to call when the button or link is clicked. This function accepts no input parameters, and can be declared inline as a dynamic function.
durationSeconds
-
Type: Number. Optionally, specify how long the notification should be displayed (in seconds) before it automatically slides up and disappears. If null or undefined, the notification will display until it is removed either by using
Notify.remove
with the uniqueId, or if the user manually dismisses the notification. - Note: duration should always be specified when displaying notifications on views. While it's not required, if the view notifications are not dismissed automatically, they may remain visible while navigating between views/forms. E.g. it's fine to display a loading notification with no duration, as long as it's removed once processing is complete.
5
bgColor
- Type: String. Optionally, specify the hex code color for the notification background. Defaults to Classic CRM yellow: "#FFF19D".
"#FFF19D"
textColor
- Type: String. Optionally, specify the hex code color for the notification text, button outlines, link colors, X color, etc. Defaults to Grey: "#444444".
"#444444"
Use this method to remove notifications from the custom notification bar on a form or view. If the unique ID matches an existing notification, that notification will slide up and be removed. If no unique ID is specified, all notifications will slide up and the custom notification bar will be hidden.
Notify.remove(uniqueId);
uniqueId
- Type: String. The unique identifier for an existing message to remove. If this is null or undefined, all notifications will be removed.
"sale"
Created by Paul Nieuwelaar - @paulnz1
Sponsored by Magnetism Solutions - Dynamics CRM Specialists