11/*
2- * given a docassemble event name, and text ID containing email address and whether
2+ * Helper function to process multiple email addresses from a string
3+ * Splits on comma or semicolon and trims whitespace
4+ */
5+ function process_multiple_emails ( email_string ) {
6+ if ( ! email_string || typeof email_string !== 'string' ) {
7+ return email_string ;
8+ }
9+
10+ // Split on comma or semicolon, trim whitespace, and filter out empty strings
11+ var emails = email_string . split ( / [ , ; ] / ) . map ( function ( email ) {
12+ return email . trim ( ) ;
13+ } ) . filter ( function ( email ) {
14+ return email . length > 0 ;
15+ } ) ;
16+
17+ // Return single string if only one email, array if multiple
18+ return emails . length === 1 ? emails [ 0 ] : emails ;
19+ }
20+
21+ /*
22+ * given a docassemble event name, and text ID containing email address(es) and whether
323 * or not user wants to send editable files, trigger docassemble event to
4- * email an ALDocumentBundle
24+ * email an ALDocumentBundle. Supports multiple email addresses separated by commas or semicolons.
525 */
626function aldocument_send_action ( event_name , wants_editable_id , email_id , template_name = "" , key = "final" , preferred_formats = null ) {
727 var editable = null ;
@@ -18,7 +38,8 @@ function aldocument_send_action(event_name, wants_editable_id, email_id, templat
1838 }
1939 }
2040
21- var email = $ ( '#' + email_id ) [ 0 ] . value ;
41+ var email_raw = $ ( '#' + email_id ) [ 0 ] . value ;
42+ var email = process_multiple_emails ( email_raw ) ;
2243 da_action_perform ( event_name , { editable : editable , email : email , key :key , template_name : template_name , preferred_formats : final_formats } ) ;
2344} ;
2445
0 commit comments