Sending custom fields as an array in a Zendesk app

Answered

Comments

7 comments

  • Avatar
    Joseph May

    Hey Ignacio-

    If you are building with our Apps Framework I'd suggest you check out the Apps Support APIs. In your case specifically I would suggest looking through the Ticket/New Ticket Sidebar location.

  • Avatar
    Ignacio De La Llave Lorenzo

    Thanks for the suggestion.

    I have checked those places a lot of time while building the apps.

    My app is loaded in the sidebar and it's changing another ticket that is linked to the currently viewed ticket so it has to be done through API (although I'm still using ZAFClient for the request).

    Regards,

  • Avatar
    Joseph May

    Sure thing, Ignacio. Have you tried to hard-code values when sending in the array? That would be the next piece I would test, as your array is otherwise formatted correctly.

  • Avatar
    Ignacio De La Llave Lorenzo

    Yes, I tried hard-coding the values (they are valid values as saving them individually works fine):

     

    newTicket.ticket.custom_fields = [{id: 25064823, value: 1785453},{id: 360011962831, value: "test"}];

     

    I'm also logging ticketData just before saving and it shows the field correctly

     

    As you see I'm passing also an array of tags which works correctly but that's an array of strings. The issue seems to be when passing an array of objects (or maybe it's just a custom fields issue)

  • Avatar
    Joseph May

    Thanks for the update, Ignacio. It sounds like you have some other variables to work through that are unique to your environment, such as custom fields. Out of curiosity, are you trying to build something similar to our Project Management App?  If so, I should let you know that the source code is available over on GitHub.

  • Avatar
    Ignacio De La Llave Lorenzo

    Hi Joseph.

    Yes I'm making something similar to the project management app in that it links tickets in the same project but quite different all in all.

    Thanks for the link. I have checked it and, strangely enough, the way of passing a custom fields array through the ZAFClient is by using the custom field id as an index in the array. So in my case

     

    updatedTicket.ticket.custom_fields = {};
    updatedTicket.ticket.custom_fields['25064823'] = 1785453;
    updatedTicket.ticket.custom_fields['360011962831'] = "test";

     

    After making that change, it's working correctly. Thank you again for your help.

     

  • Avatar
    Joseph May

    That's great to hear, Ignacio, glad that helped out! That is an interesting observation, and I will look into it more to determine if we can improve our documentation in any way.

    Thanks again for writing in and your active involvement with the Zendesk platform, and please enjoy the balance of the week.

Please sign in to leave a comment.

Powered by Zendesk