Forum Discussion

BrianCafferelli's avatar
BrianCafferelli
Qrew Captain
4 years ago

How to use Pipelines to email a report at a specific time of day

How can I email a report at a specific time of day?

Has your boss or one of your colleagues ever asked you to email them a report at a specific time of day? Sometimes it’s helpful to get a report in your inbox before an important meeting is scheduled to begin, or just to receive it before your workday begins. Read on to learn how you can set this up using Pipelines.

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:

  1. Set up a user token for the Quickbase app you want to send a report from.
  2. 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.
  3. For the first step, open the Webhooks channel.
  4. Open the Requests category, then drag the Make Request step onto the canvas.
  5. You can use the new run report API call here, so when filling out the details for the Make Request step you can:

    1. Leave the first few fields blank, from Authentication all the way down to URL.
    2. In the URL field and 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}
    3. For the Content Type, choose Application/json.
    4. For the Method, choose POST.
    5. Click More to show the other step options.
    6. You will need to enter two items under Headers, one to identify the realm your report is on, and the other to authenticate to the app. In the Name field, press <Enter> between “QB-Realm-Hostname” and “Authorization”. In the Value field, press <Enter> only after the “realm.quickbase.com” portion. Do not press enter after “QB-USER-TOKEN”. Instead, just enter a space after that, 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. So be sure not to share them with others. We have redacted a portion of the user token in the image above so it’s can’t be used.

  6. For the second step, open the Outlook channel. Connect the channel to your Outlook account if you have not already done so.
  7. Open the Emails category, then drag the Send an Email step onto the canvas.

    1. Select the Account you want to send the email from.
    2. Enter the To Addresses you want to send the email to. You can include one or more emails here.
    3. Enter the subject for your email.
    4. Enter the body of the email. You will use an HTML template here, which 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, but below is a simple example you can use to get started:
<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>



  1. To test your new pipeline, click Run pipeline at the top of the page.
  2. Once you’re done testing, click 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.

 

Further Reading


Learn More about Pipelines
No RepliesBe the first to reply