generated from microsoft/AL-Go-AppSource
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notifications for Approval Requests
- Loading branch information
1 parent
bf16574
commit 45f5910
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
MSDyn365BC.Ntfy/src/EventTypes/ApprovalRequested.Codeunit.al
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace StefanMaron.Ntfy; | ||
using Microsoft.Sales.Document; | ||
using System.Automation; | ||
|
||
codeunit 71179884 ApprovalRequestedNTSTM implements INtfyEventNTSTM | ||
{ | ||
|
||
procedure SetSettings(NtfyEvent: Record NtfyEventNTSTM) | ||
var | ||
FilterPageBuilder: FilterPageBuilder; | ||
begin | ||
FilterPageBuilder.AddTable('Approval Entry', Database::"Approval Entry"); | ||
if NtfyEvent.FilterText <> '' then | ||
FilterPageBuilder.SetView('Approval Entry', NtfyEvent.FilterText); | ||
if FilterPageBuilder.RunModal() then begin | ||
if not FilterPageBuilder.GetView('Approval Entry').Contains('WHERE') then | ||
NtfyEvent.Validate(FilterText, '') | ||
else | ||
NtfyEvent.Validate(FilterText, FilterPageBuilder.GetView('Approval Entry')); | ||
NtfyEvent.Modify(true); | ||
end; | ||
end; | ||
|
||
procedure ResetSettings(NtfyEvent: Record NtfyEventNTSTM); | ||
begin | ||
NtfyEvent.Validate(FilterText, ''); | ||
NtfyEvent.Modify(true); | ||
end; | ||
|
||
procedure FilterNtfyEntriesBeforeBatchSend(var NtfyEvent: Record NtfyEventNTSTM; Params: Dictionary of [Text, Text]); | ||
begin | ||
NtfyEvent.SetRange(UserName, Params.Get('ApproverID')); | ||
end; | ||
|
||
procedure DoCallNtfyEvent(NtfyEvent: Record NtfyEventNTSTM; Params: Dictionary of [Text, Text]) ReturnValue: Boolean | ||
begin | ||
exit(true); | ||
end; | ||
|
||
procedure GetMessage(NtfyEvent: Record NtfyEventNTSTM; Params: Dictionary of [Text, Text]) ReturnValue: Text[2048] | ||
begin | ||
exit(StrSubstNo('%1 | Pending Approval [Go to Approval List](%2)', Params.Get('RecordID'), GetUrl(ClientType::Web, CompanyName, ObjectType::Page, Page::"Requests to Approve"))); | ||
end; | ||
|
||
[EventSubscriber(ObjectType::Table, Database::"Approval Entry", OnAfterInsertEvent, '', false, false)] | ||
local procedure SentNtfyOnAfterReopenSalesDoc(var Rec: Record "Approval Entry") | ||
var | ||
NtfyEvent: Record NtfyEventNTSTM; | ||
Params: Dictionary of [Text, Text]; | ||
begin | ||
if not (Rec.Status in [Rec.Status::Open, Rec.Status::Created]) then exit; | ||
|
||
Params.Add('ApproverID', Rec."Approver ID"); | ||
Params.Add('RecordID', Format(Rec."Record ID to Approve")); | ||
NtfyEvent.SendNotifications(NtfyEvent.EventType::ApprovalRequested, Params); | ||
end; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"Ntfy", | ||
"Ntfys", | ||
"NTSTM" | ||
] | ||
], | ||
"al.rootNamespace": "StefanMaron.Ntfy", | ||
} | ||
} | ||
} |