How do I export a large project with custom fields and subtasks into a CSV or spreadsheet

custom-fields
projects

#1

We have too many tasks in a project to export to a CSV (tasks are truncated over a certain amount) so it was suggested that we export to JSON or export to Google Sheets. However, in a project’s export options (inside the dropdown next to the project’s title) I’m only seeing options for exporting to JSON, CSV, and printing. When I’ve Google’ed around for answers, some people have posted screenshot of “Google Sheets” being on their export menu, but I can’t figure out how to add that option.

I’ve tried parsing the project’s JSON feed from the API with a Google Script inside a Google Spreadsheet and I can parse out a task’s name and notes, but can’t figure out how to grab all of the custom field values and subtasks. If anyone can a tool or code they’ve used in the past (either Javascript for a Google Script or Python) to parse the JSON and export to a CSV, I’d love to see it!

Summary: We are trying to export a very large project with many tasks and custom fields within each task to a CSV, but can’t figure out a way to do it. Asana’s default CSV export seems to have a limit to what it can export by default, and it was suggested we could get more using the JSON export or through the API.


#3

And just for more context, here is the code I’m currently using in a Google Script to pull the JSON from the API and throw into a Google Sheet. This code works and I can pull all tasks in the project, but can only figure out how to get tasks by ID, name, and notes. I can’t figure out how to get any of the custom fields or subtasks inside a task.

// Based on https://gist.github.com/superstrong/b8d7413724ce311d11e672ad5d2c57c7

var options = {
	"headers" : {"Authorization": "Bearer "+ AUTH_TOKEN},
}
var response = UrlFetchApp.fetch("https://app.asana.com/api/1.0/projects/"+ PROJECT_ID +"/tasks?opt_pretty&opt_expand=(this%7Csubtasks%2B)", options);

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getSheetByName("Dashboard"); // specific sheet name to use; alternatively use ss.getActiveSheet()

var dataAll = JSON.parse(response.getContentText());
var dataSet = dataAll.data; // "data" is the key containing the relevant objects

var rows = [],
	data;

for (i = 0; i < dataSet.length; i++) {
data = dataSet[i];

	//Each JSON entity we want to pull goes below
	rows.push([
		data.id,
		data.created_at,
		data.name,
		data.notes,
	]); 
}

// Export the data to rows in the spreadsheet: [row to start on], [column to start on], [number of rows], [number of entities]
dataRange = sheet.getRange(2, 1, rows.length, 4);
dataRange.setValues(rows);

#4

Have you looked at Bridge24 as a possible alternative. www.bridge24.com


#5

Hi @keeeith,

Thanks for reaching out. Sorry you are having issues converting your large project to CSV. Have you tried the Google Sheets integration outlined on the /apps page: https://asana.com/apps/google-sheets

If this doesn’t fit your use case, you could split up the project in Asana into smaller projects and then export.

If that’s not an option, here’s the API call that the export to JSON makes:
https://app.asana.com/api/1.0/projects/180350018127066/tasks?opt_pretty&opt_expand=(this|subtasks%2B)

It is not advisable to try to get all of the data from a huge project in a single API call. Doing so can result in causing latency in the API, which may result in you getting banned from the API.

To avoid getting banned, only ask for the data you need and use pagination. For example, you could use opt_fields to only as for the objects you need:
https://app.asana.com/api/1.0/projects/180350018127066/tasks?opt_pretty&opt_fields=(this|subtasks%2B),name,id,assignee,custom_fields

You could also break this up into multiple calls:

  1. Get all task id’s in the project.
  2. For each task id, make a request to get that task, it’s custom fields, and subtasks.

Make sure to use pagination. Also, consider using the batch API so that you can make fewer request.

Let us know how it goes.


#7

@Jeff_Schneider, thanks for the reply! I added opt_fields to the “options” in the original request. Thanks for that suggestion.

I would love to use the Google Sheets integration, but can’t find a way to activate it. As I mentioned in the original post, I don’t see a “Google Sheets” export option on a project. The only place I see anything about Google Sheets is in the Dashboard, and when I click “Open Report in Google Sheets” on the Dashboard page it opens a spreadsheet that just shows me the name of the project and some metrics about it, but not individual tasks. Am I missing something and/or can you tell me how to export projects + the tasks/subtasks/customs fields into a Google Sheet?


#9

@keeeith, you’re not missing anything on the Google Sheets in Dashboards. It is a more high-level report.

There is, however, a Google Sheets export on projects. Click the project dropdown and then go to Export/Print:

I know in your original post, you said that this option was not available to you. Can you confirm. This export will hopefully solve your use case. It shows tasks, subtasks and custom fields.

If this doesn’t work, you would need to continue to build out your custom script. We are planning to write an example script that uses the Asana API to export to Google Sheets, but it likely won’t be for a few months.


#10

@Jeff_Schneider I see it now, but it was not available before yesterday. People on my team said it is not available on their end. How can we make it show up for everyone on my team?


#11

My premium edition also does not show Sync to Google Sheets