Notifications (Technical User Reference)
Â
// Simple notification example
api.notificationApi()
.withRecipient(api.user("loginName"))
.withTitle("New actionable insight found")
.withInfoStatus()
.withSource("2147483653.PL")
.withContextLink("See more", AppPages.QC_DETAILS_PAGE, [
id: "2147493269",
tpTab: 'messages'
])
.withMessage("Dashboards identified an Opportunity for you. ")
.send()
How to use Notifications API
Get NotificationApi object
api.notificationApi()
NotificationApi
provides builder-like pattern to build notification, when all is set, call send()
on it.
Set desired properties
Recipient
.withRecipient(api.user("loginName"))
There always has to be some recipient involved. You can specify a single user by its ID or login name. Or you can specify a list of users based either on IDs or login names.
.withRecipient(Long id)
.withRecipient(String loginName)
.withRecipient(List<Long>Â ids)
.withRecipientLogin(List<String>Â loginNames)
Other possibilities to set recipients are via user groups with similar inputs, group’s uniqueName, or ID.
.withUserGroupId(Long id)
.withUserGroupId(List<Long>Â ids)
.withUserGroupUqName(String uniqueName)
.withUserGroupUqName(List<String>Â uniqueNames)
Title
.withTitle("New actionable insight found")
Message
.withMessage("Dashboards identified an Opportunity for you. ")
Status
.withInfoStatus()
In this example INFO status is set for current notification.
Posible statuses for notifications are:
INFO
.withInfoStatus()
Provide additional information to users that may not be tied to their current action or task
Does not require immediate action and can be dismissed on a timer or persist, depending on the content
SUCCESS
.withSuccessStatus()
Confirm a task was completed as expected
Typically do not require further action and can be dismissed automatically or persist in a nonintrusive manner
WARNING
.withWarningStatus()
Inform users that they are taking actions that are not desirable or might have unexpected results
Often persist until the user dismisses the notification or continues in their task
ERROR
.withErrorStatus()
Inform users of an error or critical failure, and optionally block the user from proceeding until the issue has been resolved
Always persist until the user dismisses them or resolves error
Q:What are they for?
A: Status indicates serious nature of notification
Source
.withSource("2147483653.PL")
Specify some reasonably unique identifier as the source of this notification for further tracking and possible filtering in the future. Currently this doesn’t have any functional impact, but this field is mandatory.
Actions
Q: What is action?
A: Defines what happens when user clicks on notification.
Context Link
.withContextLink("See more", AppPages.QC_DETAILS_PAGE, [id: "2147493269", tpTab:'messages'])
here the parameters are: link label, target page and target page state.
context links for notifications are similar to https://pricefx.atlassian.net/wiki/spaces/KB/pages/4336648258
see
withContextLink
methods in API documentation
DOWNLOAD
.withDownloadAction(String action)
action is command for BE; you have to know the filename you want to download.
LINK
.withLinkAction(String action)
Link for fronted when you can’t or don’t want to use context linking.
Messsage LINK
.withMessageLinkAction(String action)
link to CLIC messages
INFO_MESSAGE
.withNoAction()
means notification serves the purpose as info message only. There is no intended action for a user behind this notification.
Action Label
with
.withActionLabel(String actionLabel)
you can define your action label text; by default, the source field is used.
Send it
When all needed properties are set call
send()
method on notificationApi.These fields are validated when saving before the actual send is called:
title
message
source
action and action label
status
InvalidNotificationException
can be thrown
Â
Â
Â
Found an issue in documentation? Write to us.
Â