Updating custom field values (dropdowns)

I am attempting to update via API a custom field value on a Project but am receiving the error message “Custom field with ID 1201830799946826 is not on given object”.

I created the Project and successfully associated the custom field gid 1201830799946826 to the Project via POST.

When I attempt to PUT to https://app.asana.com/api/1.0/projects/1203547940638522/ with the JSON below, I receive the error message. What is the correct JSON syntax to update the custom field value on a Project?

{
“data”: {
“custom_fields”: {
“1201830799946826”: “1201830799946827”
}
}
}

Hi @Darren_Loureiro,

I think we need some clarification about what exactly you’re wanting to do.

Are you trying to add an additional enum option to an existing enum type custom field, or something different?

Hi @Phil_Seeman , thanks for looking into my question. My ultimate goal is on the Project details page, for a Custom Field named Test-Phase, I want the value to be set as test-option-1 as opposed to the other preset options.

Test-Phase is a custom field already created in the Workspace with properties “resource_subtype”: “enum”,“resource_type”: “custom_field”,“type”: “enum”. I used POST /projects/{project_gid}/addCustomFieldSetting and successfully added Test-Phase to custom_field_settings and saw that its parent and project are the correct project. I next used PUT /projects/{project_gid} with the JSON below and received the error previously mentioned,
{
“data”: {
“custom_fields”: {
“1201830799946826”: “1201830799946827”
}
}
}

1201830799946826 is Test-Phase’s gid and 1201830799946827 is a gid of the enum_option with name test-option-1. With this attempted PUT, my expectation was to update the Project’s JSON API custom_fields from ““custom_fields”: ” to below. I believe with the steps taken and API state changed to below, I’ll then have accomplished my ultimate goal.
“custom_fields”: [
{
{
“gid”: “1201830799946826”,
“enabled”: true,
“enum_options”: [
{
“gid”: “1201830799946827”,
“color”: “yellow”,
“enabled”: true,
“name”: “test-option-1”,
“resource_type”: “enum_option”
},
{
“gid”: “1201830799946828”,
“color”: “none”,
“enabled”: true,
“name”: “test-option-2”,
“resource_type”: “enum_option”
},
],
“enum_value”: {
“gid”: “1201830799946827”,
“color”: “none”,
“enabled”: true,
“name”: “test-option-1”,
“resource_type”: “enum_option”
},
“name”: “Test Phase”,
“description”: “”,
“created_by”: {
“gid”: “1203460510854392”,
“name”: “Jane Smith”,
“resource_type”: “user”
},
“display_value”: “test-option-1”,
“resource_subtype”: “enum”,
“resource_type”: “custom_field”,
“type”: “enum”
}
}]

@Darren_Loureiro,

OK, got it. So before I explain the situation in detail, one initial question: do you have a Business or Enterprise Asana subscription, or just Premium (the differences are relevant for what you’re trying to do)?

Hi Phil, Our plan is ‘Enterprise organization’.

@Phil_Seeman

Hi @Bala_Koppella,

Hopefully you’re from the same organization as @Darren_Loureiro. :slight_smile:

In any case, I think the key point here is that there are two different levels of custom fields. You can set up custom fields at the portfolio level, in which case the values of those fields are set and stored at the project level in projects within that portfolio; and you can set up custom fields at the project level, in which case the values are set and stored in tasks within that project.

Having said that, let’s move onto Darren’s use case…

Since the goal is to affect the custom fields on the project details page, he is referring to a portfolio-level custom field.

So to do that, add the project to a portfolio, then add the custom field to that portfolio. That makes it available to set on all projects in that portfolio.

At that point, you should be able to use your PUT endpoint to set the value on the custom field in that project.