Cannot use API to set values for ticket fields if it is drop down menu

10 Kommentare

  • Ahmed Zaid
    User Group Leader Community Moderator

    Hi Sunny Wong

    You should be able to update any field type. Are you getting 422 error? Feel free to share an example of your api call.

    0
  • Holger Hansson

    I have the same issue I believe. 

    {
      "ticket": {
        "custom_fields": [{ "id": 5832450293651, "value": "australia" }]
      }
    }

    --> should update the field as far as I understand. But it does not.

    The ticket field json has this metadata (names replaced):
    {"ticket_field":{"url":"https://noname.zendesk.com/api/v2/ticket_fields/5832450293651.json","id":5832450293651,"type":"tagger","title":"Job Origin","raw_title":"Job Origin","description":"","raw_description":"","position":9999,"active":true,"required":false,"collapsed_for_agents":false,"regexp_for_validation":null,"title_in_portal":"Job Origin","raw_title_in_portal":"Job Origin","visible_in_portal":true,"editable_in_portal":true,"required_in_portal":true,"tag":null,"created_at":"2022-04-27T20:56:11Z","updated_at":"2022-05-11T09:21:04Z","removable":true,"agent_description":"PPP, Nunch, Australia","custom_field_options":[{"id":5832422001299,"name":"PPP","raw_name":"PPP","value":"usa","default":false},{"id":5833144033683,"name":"Nunch","raw_name":"Nunch","value":"nunch","default":false},{"id":5832422001427,"name":"Australia","raw_name":"Australia","value":"australia","default":false}]}}
    0
  • Ahmed Zaid
    User Group Leader Community Moderator

    Hi Holger Hansson,

    To update the value of custom field in a ticket, you need to use the ticket end point. See API reference here.

    Ticket Field end point allows you to view and edit the custom field itself (e.g. configure allowable drop down options).

    I hope that helps resolve the issue.

     

    0
  • Erica Girges
    Zendesk Developer Advocacy
    Thanks Ahmed! That's absolutely correct. The Ticket Field endpoint is to specifically create or modify the actual ticket fields themselves. If you're looking to update the value of a ticket field for a specific ticket(s), then you would want to use the Update Ticket endpoint. It's important to note that multi-select fields and dropdown fields work the same way when updating. That means you would be setting your dropdown ticket field name/id to an array with your value(s) in it.
     
    When trying to update a custom dropdown ticket field value, your request body should look similar to this:
     
    {
    "ticket": {
    "custom_fields": [
    {
    "id_dropdown_ticket_field": [
    "updated_value"
    ]
    }
    ],
    }
     
    Hope this helps!
     
    Erica
    0
  • Frank Burke

    Hello,

    I don't agree with your point that doesn't use API to set values for ticket fields if it is a drop-down menu. can you please explain to me why we don't use API????

    0
  • Christopher Kennedy
    Zendesk Developer Advocacy
    Hi Frank,
     
    Erica's comment breaks down the API endpoint you'd need to use to update an individual ticket's custom field value.  Are you running into an issue?
    0
  • Cheryl Hoskins

    I am having a similar problem using `/api/v2/tickets/create_many` endpoint. I tried using the format Erica suggests above and it still didn't work. I found that if I use the associated tag rather than the custom field, it creates the ticket as expected. Should I expect to have to use the tag rather than the custom field when using `/api/v2/tickets/create_many` endpoint?

    0
  • Tipene Hughes
    Zendesk Developer Advocacy

    Hi Cheryl,

    Yes, you'll want to be using the tag as the value, in place of the dropdown display text. Here's an article which goes in to a bit more detail:

    Setting custom field values

    I hope this helps! Let me know if you have any questions.

    Tipene

    0
  • Be Clean Nj

    Yes, this behavior is intended. When using the API to update Zendesk ticket fields, you cannot directly update fields that are dropdown menus with pre-defined values. These fields typically have limited options, and Zendesk doesn't allow API updates for such fields.

    However, if the ticket field is a free-text field, you can use the API to update its value, as there are no predefined options restricting the input.

    In summary, it is not possible to update ticket fields using the API if they are dropdown menus with pre-defined values. Only free-text fields can be updated via the API.

    0
  • Maura frankline

    This could be due to the way drop-down menus are structured in the system, which may not allow direct API input.

    In this case, you might need to explore alternative methods for updating drop-down menu fields, such as using the provided UI or finding workarounds within the system's settings. Additionally, consulting the API documentation or reaching out to the platform's support team could provide further insights or potential solutions.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

Powered by Zendesk