This article explains how to email a Quickbase report at a specified date and time.
Since Quickbase Pipelines includes the ability for you to integrate your Quickbase apps with emails in a Microsoft Outlook inbox, you can set up a scheduled pipeline to run a report, then send it to an Outlook email address:
- Set up a user token for the Quickbase app you want to send a report from.
- Create a new pipeline and give it a name. This pipeline will have two steps. The first step will run the report you want to email, and the second step will email that report.
- For the first step, open the Webhooks channel.
- Open the Requests category, then select the Make Request step.
- Fill out the details for the Make Request step:
- Leave the first few fields blank, from Authentication to URL.
- In the URL field, enter a URL like this: https://api.quickbase.com/v1/reports/{qid-of-your-report}/run?tableId={dbid-of-the-table-your-report-is-on}
- In the Method field, select POST.
- In the Content Type field, select Application/json.
- Select Additional fields to show the other step options.
- In the Headers section, you'll identify the realm your report is on, and authenticate to the app. In the Name field, select <Enter> between “QB-Realm-Hostname” and “Authorization”. In the Value field, select <Enter> only after the “realm.quickbase.com” portion. Do not select enter after “QB-USER-TOKEN”. Instead, enter a space and paste in the user token you created above.
NOTE: A user token is a form of login credentials, like a Quickbase username and password. Make sure not to share them with others. We have redacted a portion of the user token in the image above so it can’t be used.
- Add a step.
- Select the Outlook channel. Connect the channel to your Outlook account if you have not already done so.
- Open the Emails category, then select the Send an Email step
- Select the Account you want to send the email from.
- Enter the To Addresses you want to send the email to. You can include one or more emails here.
- Enter the subject for your email.
- Enter the body of the email using the HTML template below. This template includes jinja logic to process every row and column from your report and include it in the email. You can customize the HTML to adjust the visual appearance of the email message:
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
}
</style>
<h2>Report Name</h2>
<table>
<tr>{# Loop through the Fields object to create the table headers #}
{% for object in a.json.fields %}
<th>{{object['label']}}</th>
{% endfor %}
</tr>{# Loop through the records and create a row #}
{% for record in a.json.data %}
<tr>{# Loop though fields #}
{% for field in a.json.fields %} {# Grab the records field data and format based on Field Type #}
{% if field['type'] == 'percent' %}
<td>{{"{:,.2f}%".format(record[field['id'] | string]['value'] | float * 100)}}</td>
{% elif field['type'] == 'currency' %}
<td>{{"${:,.2f}".format(record[field['id'] | string]['value'] | float)}}</td>
{% else %}
<td>{{record[field['id'] | string]['value']}}</td>
{% endif %}{% endfor %}
</tr>{% endfor %}
</table>
- To test your new pipeline, select Run pipeline at the top of the page.
- Once you’re done testing, select Schedule pipeline at the top of the page to set when the email should be sent.
What’s the difference between reports I email using Report Subscriptions vs Pipelines?
When you email reports using Pipelines, you can schedule the time of day the report is sent. You can schedule which day an email subscription triggers, but for performance reasons an arbitrary time of day is assigned for each subscription. Reports emailed via Pipelines can also be customized visually, where reports emailed through Email Subscriptions have a simple design which cannot be edited.
On the other hand, subscriptions are dynamic and allow you to set up a single email subscription to potentially hundreds or thousands of people, each of whom will receive a personalized version of the report based on their permissions in the app. Reports emailed by Pipelines, however, are static. This means that all recipients will receive the same version of the emailed report. Therefore, take care that all contents of reports emailed through Pipelines are appropriate to share with all recipients of that email. Pipelines run using the permissions of the app builder who created the pipeline.