<< Click to Display Table of Contents >> Navigation: Zetadocs SDK Guide > Creating a Per Tenant Extension > Overriding the Delivery Method |
This chapter describes how it is possible to use the OnAfterGenerateSendResults events to override the Delivery Method (E-Mail/Hard Copy).
In the code example below a check is made on the purchase order to see if the amount is above 1,000, if so then the delivery method is overridden to be a Hard Copy by using the SetDeliveryMethod.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Zetadocs Customize", 'OnAfterGenerateSendResults', '', true, true)]
local procedure OnAfterGenerateSendResults(var onAfterGenerateSendResultsHandler: Codeunit "Zdd OnAfterGenerateSendResults")
var
purchaseOrder: Record "Purchase Header";
record: RecordId;
begin
onAfterGenerateSendResultsHandler.TryGetRecordId(record);
case record.TableNo() of
//For Issued Reminders, check the reminderLevel and swap the template according the level
38:
begin
//Changing Delivery Method
//if the Purchase Order is over 1,000 in value then we will want to send a hard copy.
purchaseOrder.Get(record);
//flowfield so calculate before the comparison
purchaseOrder.CalcFields("Amount Including VAT");
if (purchaseOrder."Amount Including VAT" > 1000) then begin
//Set the delivery method to "Hard Copy", other option would be "E-Mail"
onAfterGenerateSendResultsHandler.SetDeliveryMethod(ZetadocsDeliveryMethod::"Hard Copy");
end;
end;
end;
end;