How to Update Custom Fields on an Asana Task

How to Update Custom Fields on an Asana Task
Userlevel 6
Badge +1

Do you use Asana for Project and Task Management?

Do you have Custom Fields on your Asana Tasks?

If so - you might have noticed that Zapier doesn’t currently have the ability to update those Custom Fields in the Update Task action for Asana.

Whenever I see a case like this I immediately look for the answer to 2 questions.

  1. Does the Asana API use API Key for Authentication (rather than OAuth)?

  2. Does their Update Task endpoint provide the ability to update Custom Fields?

If the answer to both of those questions is “Yes” - we should be able to use Webhooks by Zapier to update the Custom Fields on the Task.

Question 1: Does the Asana API use API Key for Authentication?

It turns out they do. :)

You are able to generate a Personal Access Token (PAT) for use in API Calls.

Question 2: Does their Update Task endpoint provide the ability to update Custom Fields?

And we do have the ability to update the custom fields on a task using the Update Task endpoint.

https://developers.asana.com/docs/update-a-task

 

So both criteria for using Webhooks by Zapier to Update Custom fields on the Task are True.

Now it’s time to generate a Personal Access Token and test it out.

Generating an Asana Personal Access Token (PAT)

Asana has instructions for how to do this here:

https://developers.asana.com/docs/authentication-quick-start#app-or-pat

First we’ll navigate to this Permalink.

And once there - we’ll click the link to Generate a New Access Token.

 

We’ll Name our New Token and then click Create Token.

 

Then make sure to Copy the token and store it in a secure location.

Gathering the Required Information

In order to send the webhooks request - we’re going to need a couple of pieces of data.

First - we will need the Asana Task ID.

If you’re updating a Task - it should already exist so we would typically get the Task ID in one of 2 ways in the Zap.

  1. From the Trigger. In my example below - I’m going to use a Google Sheets Updated Row trigger to bring in the Task ID and the values I want for the Custom Field. But you may be storing it in another App which Triggers the Zap like Airtable or Pipedrive - or even using an Asana New Task in Project trigger.

  2. By searching for the Task in Zapier by using a Find Task in Project action.

The second thing we’ll need are the Custom Field IDs.

You’ll notice in Asana’s example above that the sample code looks like this.

"custom_fields": {
      "4578152156": "Not Started",
      "5678904321": "On Hold"
    }

Those Numbers on the left are the Custom Field IDs.

And we can get those in 3 steps.

  1. In Zapier - use one of the existing triggers or actions to find your Workspace ID.

  1. Put your Workspace ID into the URL structure below.

https://app.asana.com/api/1.0/workspaces/WORKSPACEID/custom_fields

  1. Make sure you’re logged into Asana and copy paste that URL with your workspace ID into your browser.

That will bring up all of your custom fields in a JSON format.

Use Ctl+F to Find or Search for the field name you’re looking for.

In my case - I have 5 Custom Fields for my test below.

The “gid” is the ID we will use to update this specific Custom Field in our Webhook Request.

Custom Text Field

{
    "gid": "1200210830546881",
    "name": "CustomText",
    "resource_subtype": "text",
    "resource_type": "custom_field",
    "type": "text"
  }

 

Custom Number Field

{
    "gid": "1200260667826518",
    "name": "CustomNumber",
    "precision": 0,
    "resource_subtype": "number",
    "resource_type": "custom_field",
    "type": "number"
  }

 

Custom Currency Field

{
    "gid": "1200260924395860",
    "name": "CustomCurrency",
    "precision": 0,
    "resource_subtype": "number",
    "resource_type": "custom_field",
    "type": "number"
  }

 

Custom Percent Field

{
    "gid": "1200260924537293",
    "name": "CustomPercent",
    "precision": 0,
    "resource_subtype": "number",
    "resource_type": "custom_field",
    "type": "number"
  }

 

Custom Drop-down Field with 3 Options

{
    "gid": "1200260725860904",
    "enum_options": [{
      "gid": "1200260725860977",
      "color": "green",
      "enabled": true,
      "name": "Test1",
      "resource_type": "enum_option"
    }, {
      "gid": "1200260725860991",
      "color": "red",
      "enabled": true,
      "name": "Test2",
      "resource_type": "enum_option"
    }, {
      "gid": "1200260819199057",
      "color": "orange",
      "enabled": true,
      "name": "Test3",
      "resource_type": "enum_option"
    }],
    "name": "CustomDropDown",
    "resource_subtype": "enum",
    "resource_type": "custom_field",
    "type": "enum"
  }

 

The Custom Drop Down options are a bit tricky - as rather than passing Asana the Name (“Test2” for example) - we’ll need to send them the GID for that option instead (1200260725860991)

Putting it All Together in a Zap

Now that we have all the pieces - we can build our test Zap.

As I mentioned above - I’m using a Google Sheets Updated Row trigger to start my Zap.

Basically - I’m adding the Task Name and ID from a separate Zap - then I want to update the Custom Fields on the Sheet to trigger my Zap and ultimately update the Asana task.

 

I have a Filter at Step 2 - so my Zap only continues once I add the word “Yes” to the Trigger Column on my Sheet above.

 

And then in Step 3 - I’m using a Webhooks by Zapier Custom Request.

Here are the important parameters on the request.

  1. The Method will be PUT

  2. The URL is https://app.asana.com/api/1.0/tasks/TASKID - where TASKID will be mapped in from another step of the Zap.

  3. The Data should follow the formatting below - you can see detailed examples including other fields that can be updated on Asana’s site here: https://developers.asana.com/docs/update-a-task

  4. There will be 2 Headers - the first is Content-type on the left - and application/json on the right

  5. The second Header is Authorization on the left - then Bearer (a space) and your Personal Access Token that you generated above.

Running the test - should update all the custom fields on my Asana task - and it does. :)

Summary

While Updating Custom Fields on an Asana Task isn’t currently built into the Asana Update Task action in Zapier - it is possible to update these fields using a Webhooks by Zapier Custom Request.

In order to do so - we need to generate a Personal Access Token from Asana and look up the ID values for our Workspace and each Custom Field.

Dropdown Custom Fields are a bit trickier since we have to pass the ID for the dropdown option to Asana and not the Name.

If you do test this out - I’d love to hear your experience (or any tips you learn) in the comments below!


28 replies

Anyone have any luck here?

 

I am getting an authorization error:

 

Failed to create a request in Webhooks by Zapier

Not Authorized (HTTP Status Code: 401)

Please help. I’ve read this multiple times and I’m still getting an error code. Not sure what I’m doing wrong?

I get the 400 error code?

 

Hi guys, I have been trying to set a Zap using a webhook, I followed this tutorial and was doing very well but I realized Zapier changed the Data section and does not accept the Json code, instead, there are fields to enter data (screenshot beow), any idea of what to put there? I know this is a very old post, so the info might not be up to date with the current version of Zapier 

 

Thanks for all the useful info - very helpful to those of us with a limited coding background!

I think I’ve followed the steps & matched up the formatting, but the Asana custom fields still aren’t populating when I run the test. My Zap is structured to trigger the creation of an Asana task (Action 1) when a Salesforce record is updated (Trigger), and I’ve tried to use the Webhooks custom request as Action 2 to update the custom fields of the task that was just created. I’m wondering if maybe I need to add some sort of delay to ensure the task ID has time to populate? Or if there’s something I’m missing in the JSON coding.

Zap steps:

 

Current custom request code:

{
"data": {
"custom fields": {
"1203775720782875": "1203791839081826",
"1203790146020630": "{{187322573__Contact_Email__c}}"
}
}
}

The test resolves with no errors but the custom field values remain null, rather than the values that should be input by the code. 

The first line attempts to populate a specific GID for a custom drop-down field choice into that field, and the second line attempts to populate a custom text field. In the JSON preview where I input the code, the “{{187322572__Contact_Email__c}}” displays as the record’s email address, and I populated it by selecting the output from earlier in the task.

Any guidance would be much appreciated, thank you! I will ultimately aim to populate additional custom drop-down fields based on inputs from the Salesforce record, but I suspect I’ll have to add an interim formatter lookup table step to match those inputs to the relevant drop-down GIDs for each custom field, so I was hoping to get the simpler piece set up first :).

 

 

I’m also having the same issue!  Not sure what I’m doing wrong here…. 

Thanks for all the useful info - very helpful to those of us with a limited coding background!

I think I’ve followed the steps & matched up the formatting, but the Asana custom fields still aren’t populating when I run the test. My Zap is structured to trigger the creation of an Asana task (Action 1) when a Salesforce record is updated (Trigger), and I’ve tried to use the Webhooks custom request as Action 2 to update the custom fields of the task that was just created. I’m wondering if maybe I need to add some sort of delay to ensure the task ID has time to populate? Or if there’s something I’m missing in the JSON coding.

Zap steps:

 

Current custom request code:

{
"data": {
"custom fields": {
"1203775720782875": "1203791839081826",
"1203790146020630": "{{187322573__Contact_Email__c}}"
}
}
}

The test resolves with no errors but the custom field values remain null, rather than the values that should be input by the code. 

The first line attempts to populate a specific GID for a custom drop-down field choice into that field, and the second line attempts to populate a custom text field. In the JSON preview where I input the code, the “{{187322572__Contact_Email__c}}” displays as the record’s email address, and I populated it by selecting the output from earlier in the task.

Any guidance would be much appreciated, thank you! I will ultimately aim to populate additional custom drop-down fields based on inputs from the Salesforce record, but I suspect I’ll have to add an interim formatter lookup table step to match those inputs to the relevant drop-down GIDs for each custom field, so I was hoping to get the simpler piece set up first :).

Userlevel 1

And if you’re wondering how to update a dropdown select custom field, this helped me:

https://forum.asana.com/t/update-custom-field-drop-down-in-a-task-through-api/144763/5?u=jared_beauchamp

Userlevel 1

I was having a really hard time updating dates and other number formats. Turns out the details of how to do that are missing from Asana’s docs, but I found it in their forum here. You have to wrap the date into it’s own json object. 

 

The format for dates are as follows:
 

“custom_fields”: {
“4578152156”: {“date”:“2022-08-18”}
}

 

I was able to use datetime format straight out of the Typeform submissions without any Formatting, but YMMV

Hi there, 

I think I am stuck where I am looking for the custom fields from the link below.

The fields that I set are just not in there. All the default fields are.

I double, tripple checked the workspace id but seems right…

What can I do?

 

Userlevel 4
Badge +1

Hi all!

Just wanted to quickly share that it is also possible to find the IDs you’re looking for by using the New Task in Project in Asana trigger and pulling in sample (see attached). 

Hope that helps!

Hello,

I believe this is the answer for my problem of updating a task’s custom field. Eventhough I read the article over 5 times, I did not understand it. Could you clarify me the solution please.
Feel free to contact me via email as well; xxxx@xxx.com

Thank You

 

This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting. 

Userlevel 7
Badge +11

Hey there, @connectTGI!

Hmm, from the look of that error it seems like Asana isn’t expecting to receive the value “Podcast”, it’s looking for an ID instead. What kind of custom field are you trying to add the value “Podcast” to, is it a Drop-down field by any chance?

If so, you’d need to use the GID (the id number for the option) instead of the option’s name (Podcast). As per Jared’s example: 

8aada2487a4f9225b25148dff65859a7.png

And to automatically convert the option name received from Gravity Forms into the correct GID number, I’d suggest adding in a Formatter (Utilities > Lookup Table) step to handle that.

Hopefully that’ll help to get it working correctly! :slight_smile:

Hello!

 

When I try to do this, I’m getting an error: 

The app returned "enum_value: Not a recognized ID: Podcast".

 

However, I’m choosing a value from my trigger, and from my test data the value just HAPPENS to be the text “podcast”. As far as I can tell, everything LOOKS similar to the example in this post.

 

Am I doing something wrong? 

 

 

Userlevel 1

Figured it out - my Task ID was incorrect 🙂 This is a great article, thank you!

Userlevel 1

Hi! I’m trying to update a custom field in Asana whenever there’s a comment added to a Jira ticket (which I plan to automate to add a comment once a day to push through the custom field update).  I keep getting the error “The app returned "task: Not a Long: 5h 49m".”.  Any thoughts on what I’m doing wrong?

Hey @SamB - thanks for the info on look up tables. That’s moreso the issue I was having as I have successfully pulled in any custom fields that are text only because that’s what’s in my google sheet. 

 

I’m just stuck on getting the text from my google sheet to convert into the GID number for the corresponding custom field option in Asana.

 

Hopefully the lookup field process works!

Userlevel 7
Badge +11

Welcome, @Ragnarok!

It looks like this section covers how Jared was able to get a list of all the ID numbers:

05210dc11fa65b085920b1fcdbc76b6b.png

For the dropdowns, you may need to set up a Formatter (Utilities > Lookup Table) step to convert the option name into the relevant ID number. You can read more about how to set up a Lookup Table here: Create lookup tables in Zaps

Hope that helps! :)

Userlevel 7
Badge +11

Hey @Lam Thai, welcome to the Community!


If custom fields aren’t returned by the existing New Task in Project Asana trigger, then you’d likely need to set up a webhook to be sent from Asana to a Zap that uses Webhooks by Zapier as the trigger app. Then you should be able to pass the information received from the Webhook over to Google Sheets using the Create Spreadsheet Row action.

I’ve not tested this myself but Asana has documentation on their webhooks and we have a guide on how to trigger Zaps from webhooks which you may find useful in setting this up! :)

Hey Jared,

This was very helpful but it seems like this doesn’t work for custom fields that have a dropdown menu unless you can somehow align your google sheet field with the custom id for the drop down field option.

I’m trying to go from an Updated Opportunity in Copper in to Google Sheets, but I have no way of getting that number into the google sheet.

 

How did you manage it?

Very great article! I just wonder… how to do it backwards, for example, I want to create a task in asana and update it to Google Spreadsheet… Currently it didn’t get the custom fields out of Asana to put into Spreadsheet

 

Thanks in advance :) 

Userlevel 6
Badge +1

Hi @Project Architect - thanks for giving that a try!

the task ID that I reference, isn’t dynamic so when the zap runs, it applies the number of custom field “hours” to the same task and not the trigger “new task”.

Is there a workaround for this? 

 

Are you getting the Asana Task Name from somewhere else in the Zap (the Trigger or Action)?

In order for it to be dynamic - we’d need to pull in the Asana Task ID from somewhere.

If it isn’t being provided by the trigger or any of the actions - we could add a Find Task in Project action to the Zap to lookup the Task and retrieve the ID from Asana.

 

So the idea would be to add the Find Task action before the webhook action so we can lookup the Task ID using the Task Name.

In that setup - we’d need some prior part of the Zap to give us the Task Name in Asana so we can use it in the Find Task step.

Then we’d map the ID from the Find Task action in dynamically to the PUT URL.

Userlevel 1

Hello there!

 

Thank you for posting this useful information on custom fields in asana.  I do have a blocker and was wondering if you can help me out. 

 

I’m trying to assign static numbers to my custom field “Hours”. I did this workflow and it works, but the task ID that I reference, isn’t dynamic so when the zap runs, it applies the number of custom field “hours” to the same task and not the trigger “new task”.

Is there a workaround for this? 

 

Below is the code I have:

 

{
  "data": {
    "custom_fields": {
      "1200113145833324": "8"
    }
  }
}

Userlevel 7
Badge +11

Hey @jonathankmg!

Thrilled to hear that you got that working, and thanks for that extra tip as well — much appreciated :)

I’d like to note one additional thing. If you find that some of your custom fields are not showing using:

https://app.asana.com/api/1.0/workspaces/<WORKSPACEID>/custom_fields

Make sure to add the custom field to the “workspace field library”. If you don’t it will not show up in the list.

(see the screenshot below which shows you how to add the field to your workspace field library)

 

 

I just wanted to report back that this worked perfectly. Thank you!

Thank you. I will give this a shot and let you know how it goes.

Reply