Advertisement
Rahul_B

Using Notifications in Business Central via AL

Feb 18th, 2024 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | Software | 0 0
  1. page 50134 "Notification Test"
  2. {
  3. ApplicationArea = All;
  4. Caption = 'Notification Test';
  5. PageType = Card;
  6.  
  7. layout
  8. {
  9. area(content)
  10. {
  11. group(General)
  12. {
  13. Caption = 'General';
  14.  
  15. field(Message; Message)
  16. {
  17. ApplicationArea = All;
  18. MultiLine = true;
  19. }
  20. }
  21. group(Data)
  22. {
  23. field(MyData; MyData)
  24. {
  25. ApplicationArea = All;
  26. Caption = 'My Data';
  27. }
  28. }
  29. }
  30. }
  31. actions
  32. {
  33. area(Promoted)
  34. {
  35. actionref(ShowNotifRef; "Show Notification")
  36. {
  37.  
  38. }
  39. actionref(HideNotifRef; "Hide Notification")
  40. {
  41.  
  42. }
  43. }
  44. area(Processing)
  45. {
  46. action("Show Notification")
  47. {
  48. ApplicationArea = All;
  49. Image = Alerts;
  50.  
  51. trigger OnAction()
  52. begin
  53. Notification.Scope(NotificationScope::LocalScope);
  54.  
  55. Notification.Message(Message);
  56. Notification.SetData('MyData', MyData);
  57. Notification.AddAction('Do Something', Codeunit::NotificationAction, 'MyAction');
  58. Notification.Send();
  59.  
  60. Notification2.Message(Message + ' + I am copy!');
  61. Notification2.Send();
  62. NotifId := Notification2.Id;
  63. end;
  64. }
  65. action("Hide Notification")
  66. {
  67. ApplicationArea = All;
  68. Image = Restore;
  69.  
  70. trigger OnAction()
  71. var
  72. NotificationL: Notification;
  73. begin
  74. NotificationL.Id(NotifId);
  75. NotificationL.Recall();
  76. end;
  77. }
  78. }
  79. }
  80.  
  81. var
  82. Message: Text;
  83. MyData: Text;
  84. Notification: Notification;
  85. Notification2: Notification;
  86. NotifId: Guid;
  87. }
  88.  
  89.  
  90. codeunit 50140 NotificationAction
  91. {
  92.  
  93. procedure MyAction(MyNotification: Notification)
  94. begin
  95. if MyNotification.HasData('MyData') then
  96. Message(MyNotification.GetData('MyData'));
  97. end;
  98. }
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement