
When managing a high volume of tasks in HubSpot, it becomes difficult to keep track of incomplete tasks that have passed their due dates. In this article, we explain how to use a Google Apps Script (GAS) library to automatically extract overdue tasks, organize them by owner, and centralize them in a Google Sheet.


The goal of this automation is to "visualize" overdue tasks and ensure zero task leakage within your team.
To use this function, you must create a "Private App" in HubSpot and issue an access token. Ensure the following scopes are granted:
Click the "Libraries +" icon on the left side of your GAS project screen, enter the Script ID below, click "Look up," and add it.
1wA-U-zBpQ6DfHLPdstfMJ51a3koDJPl7kMAq0jSpfOFvOXFCuTEwraHcHubSpotLib)Paste the following code into your editor. Refer to the comments and set the values according to your environment.
#Execution Test Code:
// library id
// 1wA-U-zBpQ6DfHLPdstfMJ51a3koDJPl7kMAq0jSpfOFvOXFCuTEwraHc
// test code
function runHubSpotTaskExport() {
// settings
const HUBSPOT_ACCESS_TOKEN = "Paste your HubSpot Access Token here"; // HubSpot Access Token
const SPREADSHEET_ID = "Paste your Spreadsheet ID here"; // Output Spreadsheet ID
const SHEET_NAME = "Sheet1"; // Name of the sheet to export to
// library identify id "HubSpotLib"
HubSpotLib.exportOverdueTasksToSheet(
HUBSPOT_ACCESS_TOKEN,
SPREADSHEET_ID,
SHEET_NAME
);
}Once executed, the following items will be automatically appended below the last row of your spreadsheet:Task ID / Subject / Due Date / Days Overdue / Owner Name / URL / Retrieval Timestamp
You need to create a HubSpot Private App and issue an Access Token. Additionally, please ensure that you grant the following two scopes (permissions): crm.objects.owners.read to retrieve owner information and crm.objects.tasks.read to retrieve task data.
The script extracts only incomplete tasks where the "Due Date" (hs_timestamp) is earlier than the current time and the "Status" is not set to COMPLETED.
A total of seven items are exported: Task ID, Subject, Due Date, Days Overdue, Owner Name, URL to the HubSpot task detail page, and the Data Retrieval Timestamp.
We can customize this sample to match your specific business requirements.
Book Free ConsultationPut it on Trello!Need a fix for HubSpot, CMS, or GAS? Post it on Trello.
Development Requests Here