Integration Belegempfänger
1. Belegempfänger in Stammdaten Karte einbinden
1.1. Anforderung
Die Belegempfänger Tabelle soll in den Stammdaten eingebunden werden. In diesem Beispiel in die Debitor Karte.
1.2. Page Extension Customer Card
pageextension 50000 CustomerCardExt extends "Customer Card"
{
layout
{
// Add changes to page layout here
addafter("E-Mail")
{
field(RecipientList; RecipientList.GetRecipientQty(Enum "CMNM Recipient Type"::Customer, Rec."No."))
{
ApplicationArea = All;
CaptionML = DEU = 'Multinav Mail Belegempfänger',
ENU = 'Multinav Mail Recipient';
trigger OnDrillDown()
begin
RecipientList.ShowCustomerRecipients(Rec);
end;
}
}
}
actions
{
// Add changes to page actions here
addlast("&Customer")
{
action(CMNMRecipient)
{
ApplicationArea = All;
Caption = 'Multinav Mail Belegempfänger',Comment = 'Multinav Mail Recipient';
Image = SendTo;
RunObject = Page "CMNM Recipient List";
RunPageLink = "Source Type" = CONST(Customer), "Source Code" = field("No.");
}
}
}
var
RecipientList: Page "CMNM Recipient List";
}
Alternativ für Kontakt Karte und Kreditor Karte:
Kontakt: RecipientList.GetRecipientQty(Enum "CMNM Recipient Type"::Contact, Rec.“No.“) | RecipientList.ShowContactRecipients(Rec)
Kreditor: RecipientList.GetRecipientQty(Enum "CMNM Recipient Type"::Vendor, Rec.“No.“) | RecipientList.ShowVendorRecipients(Rec)
2. Mehrstufige Empfängerfindung beim Versand
2.1. Anforderung
Beim Versand soll nach einem Belegempfänger gesucht werden und wenn kein Belegempfänger gefunden wurde, dann soll an die E-Mail Adresse an den Stammdaten gesendet werden. In diesem Beispiel wird nach einem Belegempfänger für die Belegart AUFTRAGSBESTÄTIGUNG gesucht und wenn kein Eintrag gefunden wird, dann soll an die E-Mail Adresse des Debitors gesendet werden.
2.2. Custom Makro erstellen
Mit dem Multinav Mail Event Mail_OnCreateMacro können Parameter definiert werden, die dann Funktionen für individuelle Anpassungen ausführen.
codeunit 50000 OnCreateMacro
{
// Diese Funktion dient als Interface für Kundenspezifische Makros
// Als Paramter werden der CMNM Posten und der Makro Befehl übergeben
EventSubscriberInstance = StaticAutomatic;
var
CMNMIntegrationInterface: Codeunit "CMNM Integration Interface";
CMNMIntegrationEvent: Codeunit "CMNM Integration Event";
[EventSubscriber(ObjectType::Codeunit, Codeunit::"CMNM Integration Event", 'Mail_OnCreateMacro', '', false, false)]
procedure ExecuteMacro(var pEntry: Record "CMNM Entry"; pMacro: Code[50]; var pMacroResult: Text; var pResult: Integer; var pProcessed: Boolean)
var
lMacro: Record "CMNM Macro";
begin
if pProcessed then
exit;
case pMacro of
'GETRECIPIENT':
pResult := GetRecipient(pEntry, pMacroResult);
else
if lMacro.Get(pMacro) then
if lMacro.Description <> '' then
pMacroResult := lMacro.Description
else
pResult := 52;
end;
pProcessed := (pResult = 0) or ((pResult <> 52) and (pResult <> 0))
end;
procedure GetRecipient(var pEntry: Record "CMNM Entry"; var pMacroResult: Text) lResult: Integer
var
lRecipient: Record "CMNM Recipient";
lCust: Record Customer;
lSalesHeader: Record "Sales Header";
lRecRef: RecordRef;
lCMNMRecipientTypeEnum: Enum "CMNM Recipient Type";
lCMNMEntryDetailType: Enum "CMNM Entry Detail Type";
lCMNMRecipientDispatchType: Enum "CMNM Recipient Dispatch Type";
lCMNMAddressSourceType: Enum "CMNM Address Source Type";
begin
lRecRef.GET(pEntry."Source RecordID");
lRecRef.SETTABLE(lSalesHeader);
// Belegempfänger suchen für Auftragsbestätigung
lRecipient.SETRANGE("Source Type", lCMNMRecipientTypeEnum::Customer);
lRecipient.SETRANGE("Source Code", lSalesHeader."Sell-to Customer No.");
lRecipient.SETRANGE("Document Type", 'AUFTRAGSBESTÄTIGUNG');
lRecipient.SETRANGE("Recipient Type", lCMNMEntryDetailType::"To");
lRecipient.SETRANGE("Dispatch Type", lCMNMRecipientDispatchType::"E-Mail");
if lRecipient.FindSet() then begin
repeat
if lRecipient."Address Source Type" = lRecipient."Address Source Type"::Custom then begin
if pMacroResult = '' then
pMacroResult := lRecipient."Custom Address"
else
pMacroResult := pMacroResult + ';' + lRecipient."Custom Address";
end else
if lRecipient."Address Source Type" = lRecipient."Address Source Type"::Contact then begin
if pMacroResult = '' then begin
lRecipient.CalcFields("Contact eMail");
pMacroResult := lRecipient."Contact eMail";
end else begin
lRecipient.CalcFields("Contact eMail");
pMacroResult := pMacroResult + ';' + lRecipient."Contact eMail";
end;
end;
until lRecipient.NEXT() = 0;
end else begin
// Alternativ suchen am Debitor
if lCust.Get(lSalesHeader."Bill-to Customer No.") then begin
if lCust."E-Mail" <> '' then begin
pMacroResult := lCust."E-Mail";
end;
end;
end;
end;
}
In Business Central wird dann noch ein neues Makro „GETRECIPIENT“ angelegt und in der E-Mail Vorlage als Empfänger Art = Makro ausgewählt.