简体   繁体   中英

All fields data not submitting to zendesk ticket form via php api

I have integrated my website from with zendesk, I am following this api library, I am successfully creating tickets to zendesk but, The problem is I am not able to send all the form fields to zendesk ticket form. Only subject and description field data is sending through my code.

This is my web form 这是我的网络表单

This is my zendesk ticket form 在此输入图像描述

This is my zendesk ticket listing 在此输入图像描述

This is My code to create ticket

 public function CreateTicketOnZendesk($subject,$email,$description,$transactionNumber){
    try{
        $client = $this->zendesk();
             $newTicket = $client->tickets()->create([
                 'subject'  => $subject,
                 'comment'  => [
                     'body' => $description
                 ],
                 'custom_fields'=>[
                     'email'  => $email,
                     'transaction_number'  => $transactionNumber,
                 ],
                 'priority' => 'normal'
             ]);
             return true;
    }catch(\Exception $e){
        error_log($e->getMessage());
    }
 }

But cannot send the email and transaction number field data tried adding these field like sending subject as well.

Custom fields should be passed as id , value pairs try using this for custom_fields . To get fields id you can go to ticket fields panel on zendesk or can use this api api/v2/ticket_fields.json

 'custom_fields'=>[
                     [
                         'id'=> '<email_field_id>', 
                         'value'=> $email
                     ],
                     [
                         'id'=> '<transaction_number_field_id>',
                         'value'=> $transactionNumber
                     ]
 ],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM