How to send a different document to two different people from the same form submission

Normally when you submit a form you assemble one or more documents and then send them to one or more email accounts.

However, you may want to assemble one document and send it to one email account (e.g. a draft document to a lawyer), and then assemble another document and send it to a different email account (e.g. a summary document to a client).

You can do this using some custom script:

$(‘#DocumentTemplateURL’).val(“https://docName1.docx”);

function BeforeAssembly(){

$(‘#DocumentEmailFrom’).val(’emailAddress1.com.au’);

// Main Document

$(‘#UsersFileID’).val( $(‘#UsersFileIDGroup’).val() );

var FormURLs = “https://docName1.docx”;

$(‘#DocumentTemplateURL’).val(FormURLs);

$(‘#DocumentEmailSubject’).val(‘Main documents for {{Client_NameLong_txt}} to be reviewed’);

$(‘#DocumentEmailRecipients’).val(’emailAddress1.com.au’);

Assemble(false);  // false turns of certain assembly functions

// Summary Document

FormURLs = “https://docName2.docx”;

$(‘#DocumentTemplateURL’).val(FormURLs);

$(‘#DocumentEmailSubject’).val(‘Summary document for {{Client_NameLong_txt}}’);

$(‘#DocumentEmailRecipients’).val(‘{{Client_email_eml}}’);

var newid = createGuid();  // create seperate document under the infofile

$(‘#UsersFileID’).val( newid );

Assemble(false);

return false;

}