IBProcessEmailDocuments.Add

Syntax

Add(Document: IBProcessEmailDocument);

Parameters

Document. Document that should be added to the collection.

Description

The Add method adds the specified document to the end of the collection.

Comments

To initialize a new document, use the BProcessEmailDocument class.

Example

Executing the example requires that the repository contains a process with the PROCESS identifier and a document with the F_HELP identifier. The file system contains the D:\Work\Report.xlsx file.

Add links to the BPM, Metabase system assemblies. Add a link to the assembly that is required to work with processes.

Sub UserProc5;
Var
    Mb: IMetabase;
    MObj: IMetabaseObjectDescriptor;
    Process: IBProcess;
    EventCollection: IBProcessEventGroupCollection;
    EventGroup: IBProcessEventGroup;
    EmailEvent: IBProcessEventEmail;
    Email: IBProcessEmail;
    Docs: IBProcessEmailDocuments;
    Doc: IBProcessEmailDocument;
Begin
    Mb := MetabaseClass.Active;
    MObj := Mb.ItemById("PROCESS");
    // Get process structure
    Process := BProcessCollection.EditByKey(MObj.Key);
    // Get the collection of groups of process events
    EventCollection := Process.Events;
    // Get group of events that occur during process startup
    EventGroup := EventCollection.ItemByType(BProcessEventType.StartProcess);
    // Create and setup of new event
    EmailEvent := New BProcessEventEmail.Create(BProcessEventType.StartProcess, "EmailEvent");
    EventGroup.Add(EmailEvent);
    Email := EmailEvent.Email;
    Email.Recipient := "first@mail.ru";
    Email.Subject := "Process execution start";
    Email.IsBodyHtml := True;
    Email.Message := "Process started. Documents are attached.";
    // Documents attached to email
    Docs := Email.Documents;
    Doc := New BProcessEmailDocument.CreateFromFile("D:\Work\Report.xlsx", Process);
    If Doc.IsPermanent Then
        Doc.SaveToPP;
    End If;
    Docs.Add(Doc);
    Doc := New BProcessEmailDocument.Create(Mb.ItemById("F_HELP"));
    Docs.Add(Doc);
    // Save changes
    If EmailEvent.IsValid Then
        Process.Save;
    End If;
End Sub UserProc;

After executing the example a new event handler, which occurs on process startup, is added for the process. The handler will send email with two attached documents. One document is based on a file, the second document is the attached repository document.

See also:

IBProcessEmailDocuments