Server Timeout Sending Large Email Attachment

My GenerateEmails form is working. I can successfully send an email with a report attached.

When I accidentally tried to send a somewhat large report, it thought for a while then came back with a server timeout message.

Is this something that can be fixed, and how long of a process will cause this message?

Thanks…

Hi Ron,

Thank you for bringing this scenario to our attention.

Could you please upload an updated version of your application to the shared folder and send me an email at elton@five.co with the steps so I can try to reproduce your scenario?

Thank you
Elton S

Hi Ron,

After investigating this scenario, I have identified two possible issues in your report design:

1 - Timeout when selecting multiple study groups:
The timeout occurs when multiple study groups are selected. This happens because Five has an internal limit of 3 minutes to generate a report. If the report is not completed within this timeframe, the process fails due to a timeout.

2 - Email not sent due to attachment size limitations:
Depending on the number of study groups selected, the email may not be sent because email providers (such as Gmail) have limits on attachment size.

For example:

  • When generating the report with the first 10 study groups selected, the PDF size is approximately 8 MB.

  • When selecting the first 20 study groups, the file size increases to around 15 MB.

An improvement can be implemented by adding a function to the “Study Group Roster” report to the event “On Run”. With this function, you can pass a configuration object to the report to control settings such as image quality and format.

For example, when selecting the first 10 study groups, the PDF size can be reduced to approximately 2 MB, compared to the previous 8 MB.

Below is an example of this function using an options object:

function SetPDFQuality(five, context, result)  {
   
    result.update('ErrErrorOk', '', '');
    result.setOptions({
        ImageQuality: 0.60,
        ImageType: 'jpeg',
    });

    return result;
}

Regards,
Elton S

Thanks for this answer, Elton.

This is a major disappointment, that there is a hard timeout after 3 minutes. I will try your code in the OnRun event. While that may help, I don’t know if it will totally solve the issue.

Can you please point me to documentation regarding this function you are suggesting? It’s not clear what the 0.60 means. I guess the lower the quality number the smaller the file?

Also, I’m confused by the ImageType: ‘jpeg’ item. Why is a PDF file having anything to do with a jpeg image?

Finally, is there ANY way that 3-minute limit can be overridden? This seems like a big show-stopper for anyone who has large reports to generate in the background.

Thanks…

Hi Ron,

I have notified the team regarding increasing the timeout. I will keep you informed of any updates.

Meanwhile, and I believe you may need it, you can generate a PDF for each studyGroup, then merge them into a single PDF when you send the email.
This is an example of how to achieve it, which I am regenerating 4 reports, combining and merging them into 3 PDF files:

function DoAddAndMergeAttachments(five, context, result)  {

const reportResult0 = five.executeAction('StaffExtension', {});

if (reportResult0.isOk() === false)   {

    return five.createError(reportResult0);

}

const reportResult1 = five.executeAction('WebProductsReport', {});

if (reportResult1.isOk() === false)   {

    return five.createError(reportResult1);

}

const reportResult2 = five.executeAction('PositionReport', {});

if (reportResult2.isOk() === false)   {

    return five.createError(reportResult2);

}

const reportResult3 = five.executeAction('StaffReport', {});

if (reportResult3.isOk() === false)   {

    return five.createError(reportResult3);

}

const pdfs1 = \[\];

const pdfs2 = \[\];

// Array pdfs1 with reports (StaffExtension and WebProductsReport) 

if (reportResult0.report) {

    pdfs1.push(reportResult0.report); 

}

if (reportResult1.report) {

    pdfs1.push(reportResult1.report); 

}

// Array pdfs2 with reports (PositionReport, and StaffReport) 

if (reportResult2.report) {

    pdfs2.push(reportResult2.report); 

}

if (reportResult3.report) {

    pdfs2.push(reportResult3.report); 

}

// Array pdfs3 with reports (StaffExtension, WebProductsReport, PositionReport, and StaffReport) 

const pdfs3 = \[\];

pdfs3.push(...pdfs1, ...pdfs2); 

 //Store the PDF utility method.       

const pdfUtils = five.pdfUtils();

//Merge reports (StaffExtension and WebProductsReport) into PDF pdf1

const mergedPDF1 = pdfUtils.merge(pdfs1);

if (mergedPDF1.isOk && mergedPDF1.isOk() === false) {

    return five.createError(mergedPDF1, 'Failed to merge pdf1 files for attaching');

}

let attachResult1 = five.addAttachment(mergedPDF1, "pdf1.pdf");

if (attachResult1.isOk() == false) {

    return five.createError(attachResult1);

}


//Merge reports (PositionReport, and StaffReport) into PDF pdf2

const mergedPDF2 = pdfUtils.merge(pdfs2);

if (mergedPDF2.isOk && mergedPDF2.isOk() === false) {

    return five.createError(mergedPDF2, 'Failed to merge pdf2 files for attaching');

}

const attachResult2 = five.addAttachment(mergedPDF2, "pdf2.pdf");

if (attachResult2.isOk() == false) {

    return five.createError(attachResult2);

}

//Merge all reports (StaffExtension, WebProductsReport, PositionReport, and StaffReport)  into PDF pdf3

const mergedPDF3 = pdfUtils.merge(pdfs3);

if (mergedPDF3.isOk && mergedPDF3.isOk() === false) {

    return five.createError(mergedPDF3, 'Failed to merge pdf3 files for attaching');

}

const attachResult3 = five.addAttachment(mergedPDF3, "pdf3.pdf");

if (attachResult3.isOk() == false) {

    return five.createError(attachResult3);

}

return five.success(result);


}

Below is the definition for the SetPDFQuality function (we are in the process of updating our documentation). The properties definition is:

ImageQuality: Set the quality of the pdf content. Example: default is 1, meaning 100%, 0.6 means 60%.

ImageType: The report generates an image for each page during PDF creation, which is then compiled and converted into a final PDF.
The supported types are ‘png’ and ‘jpeg

Regards,
Elton S