Synchronizing user and ticket fields

Answered


Posted Jul 13, 2021

Hi community,

 

since Zendesk seems to be far from an, in my opinion, normal customer service application, I need to script a solution, which just doesn't work, and due to a lack of, for me, understandable documentation, I cannot figure out where it goes wrong.

 

We are an online shop with customer service via Zendesk, and we need to get customer account numbers synced. There are primary keys in our ERP software and shop, but both are not connected to Zendesk.

I want to achieve, that if the account number is entered in a ticket, but not present in the user (customer), to write it to the customer field as well.

On the other hand, if we know the user (customer) and his/her account number, we will write it into the ticket account number field for quick reference, in case it is blank.

 

User:

custom field called "Kundennummer" with key "kundennummer"

Ticket:

custom field called "Kundennummer" with ID "********3817"

 

I have set two http-targets:

The first "pointing" to {{ticket.id}}.json:

 

The second to {{ticket.requester.id}}.json:

 

Also, I have set two triggers:

The first syncs the customer number from the user field to the ticket. Conditions are: [Status<closed] + [ticket.kundennummer = not available] + [user.kundennummer = available] (and to only affect test tickets for now: [group = management], as well as [status = changed] OR [status = new] to trigger.

Code for JSON is: 

{
"ticket": {
"custom_fields": [{
"id": ********3817, "value": "{{ticket.requester.custom_fields.kundennummer}}"
}]
}
}

 

The second syncs the customer number back from ticket to user, if the user doesn't already have a number. The trigger does pretty much the same, with inverted customer null values, uses the other http-target (though I have tried with the "sync to ticket" target as well) and this code:

{
"user": {
"custom_fields": {
"kundennummer": "{{ticket.ticket_field_********3817}}"
}
}
}

I also have pretty much tried every way of putting this, but the documentation seems to spare this usage of user custom fields completely, not telling me what exact structure and syntax I need to use here to hit the user custom field with title "Kundennummer" and key "kundennummer".

I tried to hit the field, e.g., with the following and some more:

- ticket.requester.custom_fields.kundennummer

- ticket.requester.user_fields.kundennummer

- ticket.user.user_fields.kundennummer

- ticket.user.custom_fields.kundennummer

and variations including [{"key": "kundennummer", "value": "{{variable}}"}] and such

 

The first trigger hits every time flawlessly, syncing user "kundennummer" to ticket "kundennummer".

The second trigger never works.

 

What am I doing wrong here?


0

16

16 comments

Hi,

 

I doubt this will work since the agents should be able to write this field and read from it, too.

 

What about using the user "details" field, how would you write the script then? I seem to fail understanding how the fields have to be accessed.

 

Also, does the "file name" for the http target have any impact on the outcome?

 

(edit: Of course, in the long run, we will want to sync to our ERP system, but this is not possible at the moment.)

0


Just an idea - have you tried utilizing the user field `external_id` instead of a custom field? Admittedly, I'm not sure if that will make any difference, but might be worth a try. 

But I do suggest you look into integrating your backend systems into Zendesk. We do something similar. In our case, we built custom code that evaluates every new ticket that comes in. We look at the user email and determine if there's an existing account. If so, we use the Zendesk API to update the user external_id field. We don't send it to a ticket field, but it'd be easy to do so. 

Obviously that's not an immediate solution, but it would be a more stable solution, IMO.

0


Hi, doesn't work either. But it underlines the first { bracket if I spare the ".

0


Hi Sebastian Bornemann,

okay, then try without the " " outside the placeholder.

{
"user": {
"user_fields": {
"kundennummer": {{ticket.ticket_field_********3817}}
}
}
}

0


Hi Fabio,

thanks for the answer. I just tried this (and am pretty sure to have tried that before), and without luck. The trigger gets fired (writes its tag into the ticket, so I know), but the customer number doesn't get synced...

0


I think the second JSON should say "user_fields" instead of "custom_fields":

{
"user": {
"user_fields": {
"kundennummer": "{{ticket.ticket_field_********3817}}"
}
}
}

0


Post is closed for comments.

Didn't find what you're looking for?

New post