Output a sum of custom fields using API

I’m looking to create that sum (ours is task time allocation), but using the API to pull a list of all tasks assigned to the user “unassigned” so we can display this on a screen in our office and sum the custom field to create a total amount of time.

Is it possible to use the feature you mention via API? What is the best way to do this?

@Alistair_Williams I could actually add this to CSV To Asana Simple List Generator- My Gift To Community - #24 by James_Carl if the custom field has a fixed name. Suggestions might be Est-Time Act-Time. But remember it only runs on windows PC’s.

1 Like

Hi @Alistair_Williams,

That totally seems doable. If you check out our API reference for tasks you can see what custom field values look like. In particular, this is an example of a number custom field:

{
  "data": {
    "id": 1001,
    "name": "Hello, world!",
    "completed": false,
    "...": "...",
    "custom_fields": [
      {
        "id": 134679,
        "name": "Price",
        "type": "number",
        "number_value": "1.56"
      },
      "~..."
    ]
  }
}

To sum these for a particular user, you could use the GET /tasks endpoint (mentioned a little below this header ) with the assignee parameter set to your “unassigned” user to get that assignee’s tasks, then sum the number_value of your particular custom field across all those tasks. If you only want incomplete tasks (which sounds likely), note that you can pass completed_since=now as well to get just those (it’s a strange idiom, but “completed since now” is sort of comparable to “completion date will be in the future” - so incomplete tasks)

Hopefully this inspires you to give it a go!