Hi Team,
I have created a report to fetch the user details of the application. We are getting the results if we run the manually, not getting if we schedule the same report. Any idea why it is behaving like that
I have created a report to fetch the user details of the application. We are getting the results if we run the manually, not getting if we schedule the same report. Any idea why it is behaving like that
Any suggestions on this issue
Please provide more details like
In your report, have you specified a recipient and selected an “Email Attachment Format” to send the results in PDF or CSV?
Thanks for the information.
I have scheduled a report that will trigger every day and send a mail to the recipients but we need the report name with the date in the mail attachment
Ex if it runs today - reportname with today date
Next day it should be reportname with tomorrow date
Unfortunately I don’t think that is possible. When I’ve had requirements to do that, I typically just schedule a task that calls a rule to build and email the attachment. Keeping all of the logic in the rule allows more customizations of who and what you are sending.
It’s your typical code to loop over some data and build a csv file. Throwing some code so you to get the idea:
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String fileName = "UserReport_" + formatter.format(date) + ".csv";
ByteArrayOutputStream fileData = new ByteArrayOutputStream();
fileData.write(header.getBytes(StandardCharsets.US_ASCII));
// Iterate over your csv data
for (List row : data) {
fileData.write(row.getBytes(StandardCharsets.US_ASCII));
}
EmailFileAttachment attachment = new EmailFileAttachment(fileName, EmailFileAttachment.MimeType.MIME_CSV, fileData.toByteArray());
EmaillTemplate emailTemplate = context.getObjectByName(EmailTemplate.class, "My Template");
EmailOptions options = new EmailOptions();
options.addAttachment(attachment);
options.setTo("something@something.com");
options.setVariables(new HashMap());
context.sendEmailNotification(emailTemplate, options);
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.