Versions Compared

Key

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

TL;DR

Give me some exampleSimple Notification example bellow.

Code Block
languagegroovy
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()

Explain it to me

Get NotificationApi object

api.notificationApi()

https://developer.pricefx.eu/pricefx-api/groovy/staging/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"))

...

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

...

More 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 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 source field is used.

Send it

  • When all needed properties are set call send() method on notificationApi.

  • These fields are validated when saving before actual send is called:

    • title

    • message

    • source

    • action and action label

    • status

  • InvalidNotificationException can be thrown

...