Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Simple Notification example bellow.

Code Block
language

...

java
// 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()

https://developer.pricefx.eu/pricefx-api/groovy/stagingmaster/net/pricefx/server/dto/calculation/notification/NotificationApi.html

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 possibility 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.

...

  • 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

...

A: Status indicates serious nature of notificationMore information can be found in https://www.figma.com/proto/ljgZ7bKmPFEBCIBPjolTs7/Margin-Design-System-2.0?page-id=7603%3A302232&node-id=7635%3A302390&viewport=-1339%2C3353%2C1.81&scaling=min-zoom

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 Context Linking

    • see with 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 tou 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

...