Pulling custom Org fields into ticket | The place for Zendesk users to come together and share
Skip to main content
March 1, 2018
Question

Pulling custom Org fields into ticket

  • March 1, 2018
  • 17 replies
  • 91 views

Has anyone tried or accomplished being able to pull information from custom organization fields to display in a ticket? 

 

eg: if for Customer ABC I have a custom field in the Organization profile where IT information is supplied, is there a way to put that info into every ticket as read-only? 

    This topic has been closed for replies.

    17 replies

    Jacob20
    Community Expert
    March 2, 2018

    Hi Dena,

    I've done similar things in the past. One simple(ish) way to do this would be to use the placeholder for your custom org field as a private message in a macro and have your agents apply that macro when they want to pull up that information.

    Something like this

    Note you would need to update the cool_user_field part above with the field id from your custom organization field.

    Alternatively, if you would rather have the whole thing automated, you could use a trigger or automation and an external target to update a field(s) via the API. Here is an example for a similar use case that I've used in the past. I think that would work. Such a workaround, however, is not recommended by Zendesk since there are potential conflicts that can prevent it from working reliably. 

    Hope that helps you out and welcome to the Zendesk community.

    March 2, 2018

    I do something similar

    Firstly, you’ll need to go into Settings -> Extension and setup a new HTTP target.

    • URL:  https://<your domain>/api/v2/tickets/{{ticket.id}}.json
    • Method: put
    • Comment type: JSON
    • Authentication: whatever

    Then you’ll need to create/update a trigger with:

     

    Notify Target: what whatever you called your HTTP target

    JSON body

     

    {

        "ticket": {

     

     

            "comment": {

                "public": false,

                "body":  "This customer is a member of:  \n {{ticket.requester.notes}}"

     

            }

        }

    }

     

    If it’s a custom field on the Org. then then you’ll need to refer to it as:

    {{ticket.organization.custom_fields.<whatever the field is called>}}

     

     

    Hope that makes sense

    Employee
    March 8, 2018

    Thanks for sharing, Lester!

    Randy28
    September 20, 2018

    I'm trying to do something similar to what Lester showed. I want a custom Ticket Field filled in whenever a certain custom(?) Organization Field is filled in.

    I have the HTTP Target setup (no authentication set), but the Trigger or its JSON are illuding me.

    I've set the ANY Conditions to "Status Is New" and "Status Greater than New" to hopefully make it trigger anytime.

    The JSON is currently this:


    {
        "ticket": {
            "{{ticket.ticket_field_360003547754}}": "{{ticket.organization.organization_fields.instance}}"
            }
    }

    I also tried this:

    {
        "ticket": {
            "{{ticket.ticket_field_360003547754}}": "{{ticket.organization.custom_fields.instance}}"
            }
    }

    What's confusing is that when I look at the actual JSON for the ticket, "ticket_field_360003547754" is actually more like "custom_fields.0.id.360003547754" or "custom_fields.360003547754." This confusion is further exacerbated because the JSON for the Organization I'm testing with shows "organization.custom_fields.instance" should probably be "organization.organization_fields.instance."

    I'm hoping some combination of the above is correct and it's the authentication that's causing the issues. However, if that's the case, it leads to a second question: what do I put if we're using Google for authentication? My G-Suite credentials?

    Jacob20
    Community Expert
    September 21, 2018

    Hi Randy,

    I may be out of my depths here, but I'm wondering what are the two field types (drop-down, text etc.) you want to pull the value from, and put the value to?

    A simpler trigger setup should be able to perform an update action to your custom ticket field based on a particular or any value present in your custom org field - in some cases anyway.

    About the SSO authentication issue, I believe this post answers that.

    Randy28
    September 21, 2018

    Hi Jacob,

    It's a text field to a text field. Unfortunately, the simpler trigger won't work because the available actions do not include setting custom ticket fields. If they did, this would be very easy.

    Unfortunately, while the linked article appears to be helpful, it is not solving the authorization issue. I will probably reach out to ZD support to get a better handle on this.

    Thanks!

     

    Update: I followed another link to an Intro to the Core API. They have an example I looked right past because it was using curl... So, I don't yet have the Trigger working, but the Extension now connects.

    The HTTP Target "UrL" needs to have the full URL, plus

     -u name@email.com/token:api-token-generated-by-zendesk

    and then you don't need Basic Authentication enabled.

    Mark15
    January 22, 2019

    @Randy.

    Were you able to successfully achieve this?

    I'd really like to copy the Organization (custom) field down to a Ticket (custom) field... but cannot work out the correct syntax.

    I've got lots of other targets/triggers working successfully, but this one is not clear in the API docs.

    Randy28
    January 28, 2019

    Hi Mark,

    No, I was not. And, unfortunately, if I remember Zendesk's response, it's currently impossible and if you do manage it, it's not supported. The reason was something silly like a field merge issue... Even though my requires are explicit in regards to when the Ticket Field is set...

    The only solution is to use Tags. Doing so is not pretty; it requires duplicate setup and doesn't work if anything changes (i.e. the value in the Org field changes, the Ticket field in an old ticket doesn't update). However, for all new tickets, it's flawless. We needed this functionality for two different fields. One is fairly constant and just under 100 values, so we went with the Tags solutions. However, the other would have required an ever-evolving list of over 800 values; we gave up on that and just refer to the Org field...

     

    February 5, 2019

    Hey Mark and Randy,

    I was able to figure this out after Googling and Frankensteining a couple Community posts together.

    The json used in my trigger was:

    {"ticket":
    {"custom_fields":

    [{"id":custom_ticket_field_id,
    "value":"{{ticket.requester.organization.custom_fields.field_key}}"}]


    }
    }

    The bolded portions are what you should be filling out with a custom value.

    For the ticket, the id is the custom field ID

    For the organization, however, the field key is NOT the field id. You have to go to Manage > Organization Fields and use the Field key that pops up on the right when you click on an organization field.

    Let me know if this works out for you guys.

    Mark15
    February 5, 2019

    @Martin

    Thanks for looking into this. I've got it to work!! What a genius :) Here's what my trigger looks like.

    {"ticket":
    {"custom_fields":

    [{"id":24090935,
    "value":"{{ticket.requester.organization.custom_fields.test}}"}]


    }
    }