Ruby Wrapper + Custom Fields


I’m trying to get and set custom fields inside of tasks, but can’t seem to get them. When I call custom_fields on a task that has 2 custom fields with values in them, I get “nil” as my return.


And I get “nil” back. I’m trying to pull the value of a custom field and compare it to a field in another tool. I’m new to Ruby, but I work at a place that uses it, so I’m trying to get going with it.

Any help is greatly appreciated!

You are using the official Asana Ruby API code?

Hey @Samuel_Chesser,

Thanks for reaching out. It appears that you’re using our Ruby client library. You can get custom fields values by simply querying a task. For example, if task 123456 has custom fields, requesting the task client.tasks.find_by_id(123456) will return the custom field values. You can also set custom fields on a task by passing the custom fields in the options hash.

In the code you posted, you’re calling custom_fields on a tag, which is not correct. I’m not exactly certain what you’re trying to do, but if you want to get tasks with a particular tag, you would use: client.tasks.find_by_tag({tag: <tag-id>}). This will return tasks with a particular tag (note that you will likely want to use pagination for these results). You would then need to iterate over each task if you wanted to get the tasks’ custom fields.

I suggest that you take a look at the documentation on tasks as well as the custom fields docs. Once you have an understanding of the data model, you will have better luck selecting the Ruby tasks methods that you want.

Good luck picking up Ruby!


@Bastien_Siebman I am indeed using the official code.

@Jeff_Schneider It looks like that was it, I was calling it against the tag. Duh!

Just to flesh out my use case for you a bit more: I want to link the lifecycles of tasks in Asana with Stories in Pivotal Tracker. The Zapier integration will just create tasks, but doesn’t do anything after. Once I add a tag to a task in Asana, I want it to create a story in Pivotal Tracker and then have the lifecycle of them linked, so if I change it in Asana, it changes it for the engineers in Tracker, and vice-versa. I may also have some other fields go back and forth. We have our Sales and Customer Success people in Asana, and our engineers in Tracker, and don’t want either team to have access to or work in both, but we’re losing a lot of communication that happens in Tracker so our internal stakeholders end up somewhat in the dark.

Thank you for the help!

1 Like