Skip to content

Dynamic Ship

Customizing the Dynamic Ship E-mail Template

  • This topic has 1 reply, 2 voices, and was last updated 1 year ago by Travis P..
Viewing 2 posts – 1 through 2 (of 2 total)
  • Author
    Posts
  • #8829
    Andy D.

    Hi,

    I hope we can ask developer questions here regarding customizing dynamic ship.

    I need to add two placeholders to shipping notification emails: Ship-to Code and a custom field from the Sales Header. I want these in the email body in addition to the current eight placeholders.

    I tried customizing the following two events:

    • OnAfterInitEmail (Codeunit “DSHIP Event Publisher”): fires before the “E-mail Body” BLOB is populated, so the body is empty.
    • OnBeforeSendEmail: fires before the add-on finishes composing the body. The body is rebuilt afterward, so edits are overwritten.

    Questions:

    • Is there an existing event that fires after the body is fully composed but before it’s sent to the BC email subsystem that I can use that we can use to customize the email body?
    • The placeholder array appears dimensioned for 10, but only %1..%8 are used. Are %9/%10 intended for extension? If yes, what is the supported way to populate them?

    Thank you

    #10618
    Travis P.
    Insight Works
    You had the right event. Here is some example code that will hopefully get you on the right track. For more details, please email su*****@*******ks.com.
        [EventSubscriber(ObjectType::Codeunit, Codeunit::”DSHIP Event Publisher”, ‘OnAfterInitEmail’, ”, false, false)]
        local procedure OnAfterInitEmail(recRef: RecordRef; recRefSource: RecordRef; var emailBuffer: Record “DSHIP E-mail Template” temporary; templateUsed: Code[50]);
        var
            emailBody: BigText;
            blobInStream: InStream;
            blobOutStream: OutStream;
            emailContent: Text;
            parameters: array[10] of Text;
        begin
            parameters[9] := Format(recRefSource.Field(11));
            emailBuffer.”E-mail Body”.CreateInStream(blobInStream);
            emailBody.Read(blobInStream);
            emailBody.GetSubText(emailContent, 1, emailBody.Length());
            emailContent := ReplacePlaceholders(parameters, emailContent);
            emailBuffer.”E-mail Body”.CreateOutStream(blobOutStream);
            emailBuffer.”E-mail Subject” := CopyStr(ReplacePlaceholders(parameters, emailBuffer.”E-mail Subject”), 1,
                                                            MaxStrLen(emailBuffer.”E-mail Subject”));
            blobOutStream.WriteText(emailContent);
        end;
        local procedure ReplacePlaceholders(var parameters: array[10] of Text; textToReplace: Text): Text
        begin
            exit(StrSubstNo(textToReplace, parameters[1], parameters[2], parameters[3], parameters[4], parameters[5], parameters[6],
                            parameters[7], parameters[8], parameters[9]));
        end;
Viewing 2 posts – 1 through 2 (of 2 total)
  • Sign in below to reply.