Accessing a Custom Field when creating a Task with Zoho Projects API

Accessing a Custom Field when creating a Task with Zoho Projects API

We've created a custom field called Target Date through the Zoho Projects Portal, and are now trying to access that field with information I'm passing to it. 

First we thought just formatting it as a JSON string by hand would work, but it didn't so we looked into the structure more.
When we get the project details of a task that already includes a Task Date, we get this structure:
  1.   'custom_fields' => 
        array (size=1)
          0 => 
            array (size=3)
              'column_name' => string 'UDF_DATE2' (length=9)
              'label_name' => string 'Target Date' (length=11)
              'value' => string '10-11-2019 08:00:00 AM' (length=22)
The example says to use UDF_CHAR1, so we tried that as well as the column_name attribute. We also tried naming the values of the array to what they should be, and conceivable different ways of formatting it.

This is the closest we've got, it doesn't add the Target Date but it at least doesn't break the rest of the task creation. 

  1. $targetDate = [
                                'UDF_DATE2'=>'10-17-2021 08:00:00 AM',
                            ];
  2.                         $result = $ZohoProject->createTask([
                                    'name'=>$FeeBreakdownRow->Title,
                                    'tasklist_id'=>$Parent->ZohoID,
                                    'duration'=>$FeeBreakdownRow->Hours,
                                    'description'=>$FeeBreakdownRow->Description,
                                    'start_date'=>date('m-d-Y'),
                                    'custom_fields[]' => json_include($targetDate),
                                    'duration_type'=>'hrs',
                                    'work_type'=>'work_hours',
                                    'task_duration_as_work'=>'true',
                                    'person_responsible'=>$ZohoProject->findUserIDFromEmail($FeeBreakdownRow->OwnerEmail),
                                ]);
      And createTask:
  1.           public function createTask($params=[],$projectID=''){   
            $projectID  = ($projectID)?$projectID:$this->projectID
            $default_params = array(
                'priority'=>'None',
                'authtoken'=>self::AuthToken(),
            );
            $url = self::BASE_URL.'/portal/'.$this->portalID.'/projects/'.$projectID.'/tasks/';
            //var_dump($params);
            return $this->parseResponse($this->doRequest($url,array_replace($default_params,$params),'POST'));
        }

If there was an example that used a date I'm sure I could figure out how it works, but right now I feel like we've guessed everything it can possibly be and haven't had any luck yet. An example, or some pointers on what I'm doing wrong would be very helpful. Thanks!

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now