<< Click to Display Table of Contents >> Navigation: Zetadocs SDK Guide > Zetadocs SDK API > OnBeforeDelivery |
OnBeforeDelivery Event
Runs after the original attachment has been applied to the email, and before the email has been sent out.
Publisher
[IntegrationEvent(false, false)]
procedure OnBeforeDelivery(var ZdOnBeforeDeliveryHandler: Codeunit "Zetadocs OnBeforeDelivery")
begin
end;
Subscriber
To subscribe to this event, you will need to decorate the subscriber method with the correct EventSubscriber attributes:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Zetadocs Customize", 'OnBeforeDelivery', '', true, false)]
Zetadocs OnBeforeDelivery codeunit
This codeunit exposes procedures that allow you to modify the Emails sent by Zetadocs. The following methods are currently available on instances of the OnBeforeDelivery data type.
Method name |
Description |
---|---|
AddOrUpdateAdditionalAttachments (Text, Text, Text) |
Add or Updates a reference to an additional file to be attached to an email, a reference to any stationary to be applied, and a document link value used to tie an additional attachment to a specific email attachment. |
AddOrUpdateTemplateValue(Text, Text) |
Adds or updates the template value for the specified key. |
GetAdditionalAttachments(var Dictionary of [Text, Text]) |
Returns the current list of Additional Attachments to be sent with the email. |
GetRecordIds(var List of [RecordId]) |
This method will get the list of records being emailed, if the email is a consolidated batch it will retrieve every record in the batch. |
GetReports(var List of [Text]) |
Gets the list of reports sent with the Delivery. |
GetSendingUserMethod(): Text |
Get the user who ordered the Delivery action. |
GetTemplateValues(var Dictionary of [Text, Text]) |
Gets the dictionary of key value pairs that will be applied to the document template. |
RenameReport(Text, Text) |
Rename the report file. |
TrySearch(List of [recordId], List of [Dictionary of [Text, Text]): Boolean |
Use this method to search for any related documents associated to the list of recordId’s given. |
This method will propagate any errors raised in the event subscriber back to Zetadocs Capture and Delivery |
|
SetError(Text) |
This method can be used to send a custom error message to Zetadocs Capture and Delivery. |
Init(Record "Zetadocs Send Result") |
This method is called internally by the publisher, a call to this method will return an error. |
AddOrUpdateAdditionalAttachments Method
Will take a link to a SharePoint Online file, optionally a link to a Stationary file, if the file link already exists it will update the stationary link, otherwise it will add these to the email being sent, and a final optional value is for the document link, which is used to link an additional attachment to a specific attachment, this is needed when using the Combine Documents option in Zetadocs.
Syntax
OnBeforeDeliveryHandler.AddOrUpdateAdditionalAttachments(FileFullReference: Text, StationeryReference: Text, LinkedDocumentKey: Text);
Parameters
FileFullReference
Type: Text
A link to a file on SharePoint online, for example “https://condoso.microsoft.com/Sharepoint/File1.pdf”.
StationaryReference
Type: Text (Optional)
Name of a file uploaded to the Templates folder via the Zetadocs Tempalte page.
LinkedDocumentKey
Type: Text (Optional)
Document Number that the Additional Attachment belongs to, for example to link to Sales Order 1001, the value would be 1001.
AddOrUpdateTemplateValue Method
Adds or updates the template value for the specified key.
Syntax
OnBeforeMsgDelivertHandler.AddOrUpdateTemplateValue(keyName: Text, value: Text);
Parameters
keyName
Type: Text
The key that will be changed, it must match the key in the document template.
value
Type: Text
The value that will replace the key in the document template.
GetAdditionalAttachments Method
Get the dictionary of additional attachments to be applied to the email.
Syntax
OnBeforeDeliveryHandler.GetAdditionalAttachments(var Attachments: Dictionary of [Text, Text]);
Parameters
Attachments
Type: Dictionary of [Text, Text]
The current instance of additional attachments and stationary files to be applied to the email.
The purpose of this method is to retrieve all the records that are being emailed, emails can be a single delivery (single record was selected), a batch delivery (multiple records were selected) for multiple customers or a consolidated batch (multiple records selected for the same customer). So, the email could contain multiple records, this method will retrieve the records dependant on the type of delivery. You can then use the output to search for related documents.
Syntax
onBeforeDeliveryHandler.GetRecordIds(recordIds: List of [recordId]);
Parameters
recordIds
Type: List of [recordId]
The returned list of records selected for emailing.
Get the list of Report file names to be applied to the email.
Syntax
OnBeforeDeliveryHandler.GetReports(var Reports: List of [Text]);
Parameters
Reports
Type: List of [Text]
The current filenames of the Reports to be attached to the email.
Get the user who ordered the Delivery action.
Syntax
OnBeforeDeliveryHandler.GetSendingUser() sendingUser: Text
Parameters
N/A
Gets the dictionary of key value pairs that will be applied to the document template.
Syntax
OnBeforeMsgDelivertHandler.GetTemplateValues(var templateValues: Dictionary of [Text, Text]);
Parameters
templateValues
Type: Dictionary of [Text, Text]
The dictionary of template key value pairs that have been added.
Rename the report file to be added to the email.
Syntax
OnBeforeMsgDelivertHandler.RenameReport(oldName: Text; newName: Text);
Parameters
oldName
Type: Text
Name of the report file to be renamed.
newName
Type: Text
Name that should replace the previous name of the report file.
This method gives you the ability to retrieve the list of documents from SharePoint that are associated with the Business Central records. For performance reasons it is best to build up a list of Record Id then perform the search once.
Syntax
OnBeforeDeliveryHandler.Search(recordIds: List of [recordId]; var searchResultDictionary: List of [Dictionary of [Text, Text]]) WasSearchSucess: Boolean
Parameters
recordIds
Type: List of [RecordId]
This list of Business Central records will be used to search for linked documents in SharePoint.
searchResultDictionary
Type: List of [Dictionary of [Text, Text]]
You should iterate over the list to retrieve a further dictionary, containing the metadata for the related file. The currently available metadata is as follows:
Modified, FileName, Url, DocumentReference, DocumentType.
Return Value
WasSearchSucess
Type: Boolean
Indicates if the search to SharePoint was successfull.
This method should be used to push errors that have been raised by Zetadocs Capture and Delivery to declare stop the process execution.
Syntax
OnBeforeDeliveryHandler.PropagateLastError();
This method is used to pass any custom errors to Zetadocs.
Syntax
OnBeforeDeliveryHander.SetError(errorText: Text);
Parameters
Type: Text
The error message to pass to Zetadocs.
Initialises the OnBeforeDelivery object with the relevant information. This will be done internally and is not for 3rd parties consumption.