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.
- Loading branch information
1 parent
814ffa4
commit 6665aaa
Showing
5 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
MSDyn365BC.Ntfy/src/foundation/EventTypes/MyCodeunit.Codeunit copy.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,52 @@ | ||
namespace StefanMaron.Ntfy; | ||
using Microsoft.Sales.Document; | ||
using System.RestClient; | ||
|
||
codeunit 71179877 SalesDocumentReleasedNTSTM implements INtfyEventNTSTM | ||
{ | ||
|
||
procedure SetFilters(NtfyEntry: Record NtfyEntryNTSTM) | ||
var | ||
FilterPageBuilder: FilterPageBuilder; | ||
begin | ||
FilterPageBuilder.AddTable('Sales Header', Database::"Sales Header"); | ||
if FilterPageBuilder.RunModal() then begin | ||
NtfyEntry.Validate(FilterText, FilterPageBuilder.GetView('Sales Header')); | ||
NtfyEntry.Modify(true); | ||
end; | ||
end; | ||
|
||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Release Sales Document", OnAfterReleaseSalesDoc, '', false, false)] | ||
local procedure SentNtfyOnAfterReleaseSalesDoc(var SalesHeader: Record "Sales Header") | ||
var | ||
FilterSalesHeader: Record "Sales Header"; | ||
NtfyEntry: Record NtfyEntryNTSTM; | ||
RestClient: Codeunit "Rest Client"; | ||
Body: Codeunit "Http Content"; | ||
DoCall: Boolean; | ||
begin | ||
NtfyEntry.SetRange(EventType, NtfyEntry.EventType::SalesDocumentReleased); | ||
NtfyEntry.SetFilter(NtfyTopic, '<>%1', ''); | ||
if NtfyEntry.FindSet() then | ||
repeat | ||
Clear(Body); | ||
Clear(RestClient); | ||
Clear(FilterSalesHeader); | ||
DoCall := false; | ||
|
||
if NtfyEntry.FilterText <> '' then begin | ||
FilterSalesHeader.SetView(NtfyEntry.FilterText); | ||
FilterSalesHeader.FilterGroup(2); | ||
FilterSalesHeader.SetRange(SystemId, SalesHeader."SystemId"); | ||
DoCall := not FilterSalesHeader.IsEmpty(); | ||
end; | ||
|
||
if DoCall then begin | ||
Body.Create(StrSubstNo('Sales %1 - %2 - has been released', SalesHeader."Document Type", SalesHeader."No.")); | ||
RestClient.Post(StrSubstNo('https://ntfy.sh/%1', NtfyEntry.NtfyTopic), Body).GetContent().AsText(); | ||
end; | ||
until NtfyEntry.Next() = 0; | ||
|
||
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