Interface NotificationApi


public interface NotificationApi
The NotificationApi interface is used for configuring Notifications.

This API interface uses the builder pattern to set the Notification's properties. Once all is configured, the send() method posts the Notification. At this point, the Notification is validated to ensure its properties are set correctly. User logins and User Groups are validated when send() is called. When used within the Input Generation Execution, you can save a logic with Notification referencing non existent users or groups. At least one user or user group must be specified as a recipient.
Supports the following actions when a user clicks on the notification:

  • Context Link
  • Download
  • Link
  • Message Link
  • Info Message

See Also:
  • Method Details

    • withTitle

      NotificationApi withTitle(String title)
      Sets the title of the Notification. This field is mandatory.
      Example:
      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withInfoStatus()
               .withTitle("The Title")
               .withMessage("No action needed")
               .withNoAction()
               .withSource("2147491340.Q")
               .send()
       
      Parameters:
      title - The title of the Notification.
      Returns:
      this NotificationApi
    • withMessage

      NotificationApi withMessage(String message)
      Specifies the message of the Notification. This field is mandatory when withNoAction() is used.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withInfoStatus()
               .withTitle("The Title")
               .withMessage("No action needed.")
               .withNoAction()
               .withSource("2147491340.Q")
               .send()
       
      Parameters:
      message - The text content of the Notification message.
      Returns:
      this NotificationApi
    • withInfoStatus

      NotificationApi withInfoStatus()
      Sets the status of the Notification to INFO.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withInfoStatus()
               .withTitle("The Title")
               .withMessage("No action needed.")
               .withNoAction()
               .withSource("2147491340.Q")
               .send()
       
      Returns:
      this NotificationApi
    • withErrorStatus

      NotificationApi withErrorStatus()
      Sets the status of the Notification to ERROR.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withErrorStatus()
               .withTitle("The Title")
               .withMessage("An error occurred.")
               .withSource("2147491340.Q")
               .withContextLink("Products", AppPages.MD_PX_PAGE)
               .send()
       
      Returns:
      this NotificationApi
    • withWarningStatus

      NotificationApi withWarningStatus()
      Sets the status of the Notification to WARNING.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withWarningStatus()
               .withTitle("The Title")
               .withMessage("I warn you.")
               .withSource("2147491340.Q")
               .withContextLink("Products", AppPages.MD_PX_PAGE)
               .send()
       
      Returns:
      this NotificationApi
    • withSuccessStatus

      NotificationApi withSuccessStatus()
      Sets the status of the Notification to SUCCESS.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withSuccessStatus()
               .withTitle("The Title")
               .withMessage("Successfully completed!)
               .withSource("2147491340.Q")
               .withContextLink("Products", AppPages.MD_PX_PAGE)
               .send()
       
      Returns:
      this NotificationApi
    • withLinkAction

      NotificationApi withLinkAction(String action)
      Sets the action type of the Notification to LINK. LINK action type is used for FE redirects to a specific page.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withWarningStatus()
               .withTitle("The Title")
               .withSource("2147491340.Q")
               .withLinkAction("qc/custom-forms/7.CFOT/264.CFO")
               .send()
       
      Parameters:
      action -
      Returns:
      this NotificationApi
    • withDownloadAction

      NotificationApi withDownloadAction(String action)
      Sets the action type of the Notification to DOWNLOAD. DOWNLOAD action type is used for BE cmd calls to get stored exports.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withWarningStatus()
               .withTitle("The Title")
               .withSource("2147491340.Q")
               .withDownloadAction("asyncdownloadmanager.download/Pricefx_seeddata_DMDS_TXStandardData_20221019_190615_ilZHL.xlsx")
               .send()
       
      Parameters:
      action - to be performed when clicked on notification.
      Returns:
      this NotificationApi
    • withNoAction

      NotificationApi withNoAction()
      Sets the action type of the Notification to INFO_MESSAGE. INFO_MESSAGE is used for messages without an action, the message is required when no action is specified.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withInfoStatus()
               .withTitle("The Title")
               .withMessage("No action needed.")
               .withNoAction()
               .withSource("2147491340.Q")
               .send()
       
      Returns:
      this NotificationApi
    • withMessageLinkAction

      NotificationApi withMessageLinkAction(String action)
      Sets the action type of the Notification to the message link. Message link is used to redirect to a specific CLIC Message page/tab. Available for CLIC modules only i.e., Quotes, Contracts, Rebates, Sales Compensation.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withInfoStatus()
               .withTitle("The Title")
               .withMessage("Check this message!")
               .withSource("2147491340.Q")
               .withMessageLinkAction("Q/2147491329/45")
               .send()
       
      Parameters:
      action - The link to the CLIC message.
      Returns:
      this NotificationApi
    • withSource

      NotificationApi withSource(String source)
      Sets the source of the Notification. This field is mandatory. Does not have a functional impact.
      The source of the Notification should be something reasonably identifiable (a unique identifier), like a TypedId: e.g. PL.101. This can be used for further tracking and possible filtering in the future.
      Parameters:
      source - The source of the Notification.
      Returns:
      this NotificationApi
    • withRecipient

      NotificationApi withRecipient(Long id)
      Sets the recipient of the Notification. A recipient or a user group must be set. Replaces current recipients (users and groups).

      Example:

      
         api.notificationApi()
               .withRecipient(api.user()?.id)
               .withTitle("The Title")
               .withSource("2147491340.Q")
               .withSuccessStatus()
               .withContextLink("Follow this link", AppPages.QC_DETAILS_PAGE, "2147491340.Q")
               .withMessage("A message for you:")
               .send()
                           }
       
      Parameters:
      id - The user id as the recipient.
      Returns:
      this NotificationApi
    • withRecipient

      NotificationApi withRecipient(List<Long> ids)
      Sets recipients of the notification. A recipient or a user group must be set. Replaces current recipients (users and groups).
      Parameters:
      ids - User ids of recipients.
      Returns:
      this NotificationApi
    • withRecipient

      NotificationApi withRecipient(String loginName)
      Sets the recipient of the Notification. A recipient or a user group must be set. Replaces current recipients (users and groups).

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withTitle("The Title")
               .withSource("2147491340.Q")
               .withSuccessStatus()
               .withContextLink("Follow this link", AppPages.QC_DETAILS_PAGE, "2147491340.Q")
               .withMessage("A message for you:")
               .send()
                           }
       
      Parameters:
      loginName - The user login name of the recipient.
      Returns:
      this NotificationApi
    • withRecipientLogin

      NotificationApi withRecipientLogin(List<String> loginNames)
      Sets recipients of the notification. A recipient or a user group must be set. Replaces current recipients (users and groups).
      Parameters:
      loginNames - User login names of recipients.
      Returns:
      this NotificationApi
    • withUserGroupUqName

      NotificationApi withUserGroupUqName(String uniqueName)
      Sets the user group as the recipient of the notification. A recipient or a user group must be set. Replaces current recipients (users and groups).
      Parameters:
      uniqueName - The user group uniqueName of the recipient.
      Returns:
      this NotificationApi
    • withUserGroupUqName

      NotificationApi withUserGroupUqName(List<String> uniqueNames)
      Sets user groups as recipients of the notification. A recipient or a user group must be set. Replaces current recipients (users and groups).
      Parameters:
      uniqueNames - User group uniqueNames as recipients.
      Returns:
      this NotificationApi
    • withUserGroupId

      NotificationApi withUserGroupId(Long id)
      Sets the user group as the recipient of the notification. A recipient or a user group must be set. Replaces current recipients (users and groups).
      Parameters:
      id - The user group id of the recipient.
      Returns:
      this NotificationApi
    • withUserGroupId

      NotificationApi withUserGroupId(List<Long> ids)
      Sets user groups as recipients of the notification. A recipient or a user group must be set. Replaces current recipients (users and groups).
      Parameters:
      ids - User group ids of recipients.
      Returns:
      this NotificationApi
    • withContextLink

      NotificationApi withContextLink(String targetPage)
      Sets the action type of the Notification to context link. The link opens the target AppPage Uses the internal application linking. The message field will be used as the action label.

      Example:

      
          api.notificationApi()
                 .withRecipient(api.user("loginName"))
                 .withTitle("The Title")
                 .withSource("2147491340.Q")
                 .withSuccessStatus()
                 .withContextLink(AppPages.MD_PRODUCTS_PAGE)
                 .withMessage("See Products")
                 .send()
       
      Parameters:
      targetPage - A page from AppPages
      Returns:
      this NotificationApi
      See Also:
    • withContextLink

      NotificationApi withContextLink(String targetPage, Object targetPageState)
      Sets the action type of the Notification to context link. The link opens the target AppPage and thespecified detail. Uses the internal application linking. The message field will be used as the action label.

      Example:

      
          api.notificationApi()
                 .withRecipient(api.user("loginName"))
                 .withTitle("The Title")
                 .withSource("2147491340.Q")
                 .withSuccessStatus()
                 .withContextLink(AppPages.QC_DETAILS_PAGE, [id: "2147494231", tpTab:'messages'])
                 .withMessage("See the Quote messages")
                 .send()
       
      Parameters:
      targetPage - A page from AppPages.
      targetPageState - The state of the targetPage, or a sub-page of the targetPage. For example, targetPage=AppPages.MD_PRODUCTS_PAGE and targetPageState=MB-00001 leads to the product detail page for the sku MB-00001.
      Returns:
      this NotificationApi
      See Also:
    • withContextLink

      NotificationApi withContextLink(String actionLabel, String targetPage, Object targetPageState)
      Sets the action type of the Notification to context link. The same functionality as withContextLink(String, Object) but sets also the label of the link.
      Overrides the label set by withMessage(String).

      Example:

      
          api.notificationApi()
                 .withRecipient(api.user("loginName"))
                 .withTitle("The Title")
                 .withSource("2147491340.Q")
                 .withSuccessStatus()
                 .withContextLink("The Label", AppPages.QC_DETAILS_PAGE, [id: "2147494231", tpTab:'messages'])
                 .withMessage("See the Quote messages")
                 .send()
       
      Parameters:
      actionLabel - By default, 'message' will be used, this method overrides the default label.
      targetPage - page from @link AppPages
      targetPageState -
      Returns:
      this NotificationApi
      See Also:
    • withContextLink

      NotificationApi withContextLink(String actionLabel, String targetPage)
      Set action type of the Notification to context link. Uses internal application linking.
      Parameters:
      actionLabel - by default 'source' will be used, this label will override it.
      targetPage - page from @link AppPages
      Returns:
      this NotificationApi
      See Also:
    • withActionLabel

      NotificationApi withActionLabel(String actionLabel)
      Sets the action label of notification.
      Parameters:
      actionLabel - actionLabel by default 'source' will be used, this label will override it.
      Returns:
      NotificationApi
    • send

      void send()
      Validates currently configured Notification and sends it to Notification center if valid.

      Example:

      
         api.notificationApi()
               .withRecipient(api.user("loginName"))
               .withSuccessStatus()
               .withTitle("The Title")
               .withMessage("Successfully completed!)
               .withSource("2147491340.Q")
               .withContextLink("Products", AppPages.MD_PX_PAGE)
               .send()
       
      The send() method validates the following fields when called:
      • title
      • message
      • source
      • action
      • actionLabel
      • status
      Can throw the InvalidNotificationException