Add custom field value

Hey Everyone.

We have 2 custom fields in a Task that I need to put data into.
Those are “Ordernumber” and “Salesman”.

I think I have got the correct ID of the fields (Not sure).
But how do I add data into this.
Documentation is not very clear here and is making my head hurt.

This is the code I have now. Where and how do I add custom field values here for my 2 fields?

curl_setopt_array($curl, array(
                        CURLOPT_URL => 'https://app.asana.com/api/1.0/tasks',
                        CURLOPT_RETURNTRANSFER => true,
                        CURLOPT_ENCODING => '',
                        CURLOPT_MAXREDIRS => 10,
                        CURLOPT_TIMEOUT => 0,
                        CURLOPT_FOLLOWLOCATION => true,
                        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                        CURLOPT_CUSTOMREQUEST => 'POST',
                        CURLOPT_POSTFIELDS => array('name' => '' . $adname . '', 'projects' => '1201177956477737', 'notes' => '' . $main_brief . '', 'assignee' => '1199508896039720'),
                        CURLOPT_HTTPHEADER => array(
                            *****
                        ),

                    ));

Hi @Joakim_Paulsen,

I’m not familiar with that particular syntax/language, but take a look at the example shown on the right-hand side of the docs, under “Body parameter”, here:

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

It shows you how to format custom field values on a task. The only other thing to mention is that the two custom fields they show are both text custom fields, because the values shown are English text strings. If you are updating an enum custom field, the second value would be the gid of that enum value; so for example, if the second of those fields was an enum field, it might look like this:

"custom_fields": {
      "4578152156": "Not Started",
      "5678904321": "9003287851"
}

And for a multi_enum, it would be an array of enum values, like this:

"custom_fields": {
      "4578152156": "Not Started",
      "5678904321": ["459021796", "1004598149"]
}
1 Like

This topic was automatically closed after 6 days. New replies are no longer allowed.