Extract date from subject and pass it to a custom field

Respondidas


Publicado 01 nov 2023

Hello,

We have given our customers a standard subject line that they can use to raise tickets. Something like this: Booking No. // Request Type// MM-DD-YYYY

I want to extract the MM-DD-YYYY and pass that value to a custom field so that we can run SLA based on this field and prioritize case accordingly.

Please point me in the right direction on how to do this, thanks!


1

8

8 comentarios

Amazing! Thank you 1263169425010  and 1263169182210.  Very helpful!!

 

One quick follow up, if i wanted to extract an 8-digit number from the subject line (which is really exactly my use case), could I use this? how would it be different? Any help is greatly appreciated! 

 

Thank you!

 

 

 

 

 

0


Hi 1263169182210 and 1263169253750 

 

I have not tested this, but using liquid markup to parse the subject line text should allow you to extract the two values you want and update the text fields with them.


For a subject line “Onboarding Request ABC|123”, the below webhook payload should extract the “ABC”  value and set it to the field with the ID 19626217318ABC, and for “123” set it on the field with ID 19626217318123.

{
    "ticket": {
        "custom_fields": [
            {
                "id": 19626217318ABC,
                "value": "{% assign parts = ticket.title | split: '|' %}{% assign value1 = parts[0] | split: ' ' | last %}{{ value1 }}"
            },
            {
                "id": 19626217318123,
                "value": "{% assign parts = ticket.title | split: '|' %}{% assign value2 = parts[1] | strip %}{{ value2 }}"
            }
        ]
    }
}

1


Sadly not 1263169253750 .

0


Hi 1263169425010 and 1263169182210

Was there ever any resolution to this as I have the same exact use case and would love to be able to automate this. 

Subject - Onboarding Request ABC|123


{
   "ticket": {
       "custom_fields": [
           {
               "id": 19626217318541,
               "value": "{% assign parts = ticket.title | split: "|" %}<NEED TO KNOW WHAT GOES HERE TO ASSIGN VALUE ABC>"
           }
       ]
   }
}

Thanks!

Rich

0


I have a perhaps much simpler question related to this that I suspect will help many other people. What if we wanted to not assign a date value per se, but just a string immediately before/after a delimiter (say ‘|’). Ideally, I would like to be able to populate two custom fields one with the ‘ABC’ value and another with the ‘123’ value, but If I could get the syntax for just populating ‘ABC’ to a custom field that would be very helpful. Below is a sample subject and part of the code.

 

Thanks.

 

Subject - Onboarding Request ABC|123


{
   "ticket": {
       "custom_fields": [
           {
               "id": 19626217318541,
               "value": "{% assign parts = ticket.title | split: "|" %}<NEED TO KNOW WHAT GOES HERE TO ASSIGN VALUE ABC>"
           }
       ]
   }
}

 

0


Hey 5217384669210

If you don't already have a webhook set up, you can follow steps 1 and 2 in this article: https://support.zendesk.com/hc/en-us/community/posts/5721747041434-Prevent-Thank-you-replies-from-reopening-tickets

When setting the URL, the article 👆 says to use "https://domain.zendesk.com/api/v2/tickets/update_many.json?ids={{ticket.id}}", but you could use "https://domain.zendesk.com/api/v2/tickets/{{ticket.id}}" for this use case.

For your trigger, I would use the ticket is created condition, along with other conditions to make sure that it only fires for the relevant tickets you want to do this for.
While testing, you may also want a condition in there where "current user" is you, so it only fires for your test tickets.

In the Action section, select Notify Webhook and select the webhook you have created for this.

Please find the ID for the date field you want to fill out in the example mine is 19626217318541, update the ID in the below payload for yours.

{
    "ticket": {
        "custom_fields": [
            {
                "id": 19626217318541,
                "value": "{% assign parts = ticket.title | split: "//" %}{% assign date_parts = parts[2] | strip | split: "-" %}{% assign formatted_date = date_parts[2] | append: "-" | append: date_parts[0] | append: "-" | append: date_parts[1] %}{{formatted_date}}"
            }
        ]
    }
}

You can find a field's ID in your admin center: Objects and rules > Tickets > Fields.

I hope that helps you out.

0


Thanks 1263169425010. This liquid markup gives me the date output that i'd want.

I have a custom date field called "booking-date' where I want to fill this data.  Can you help me with the final step of appending the date in this date field.

0


Hey 5217384669210

You may be able to use a trigger and webhook to update a ticket date field using some Liquid Markup like the below:

{% assign parts = ticket.title | split: "//" %}
{% assign date_parts = parts[2] | strip | split: "-" %}
{% assign formatted_date = date_parts[2] | append: "-" | append: date_parts[0] | append: "-" | append: date_parts[1] %}
{{formatted_date}}

I haven't tested the above, but if your subject line always follows the structure you indicated and that date format, it should be able to output the date format that a ticket date-type field accepts "YYYY-MM-DD".

 

 

0


Iniciar sesión para dejar un comentario.

¿No encontró lo que buscaba?

Nueva publicación