Recent searches


No recent searches

Validation error when setting custom field



Posted Dec 06, 2024

I'm trying to update a custom field value via the API. I'm using a PUT request to /api/v2/tickets/<ticketID>.json I'm getting a validation error as follows:

{
  "error": "RecordInvalid",
  "description": "Record validation errors",
  "details": {
    "base": [
      {
        "description": "Incident vs. Service Request: needed",
        "error": null,
        "ticket_field_id": 21621964218653,
        "ticket_field_type": "FieldTagger"
      }
    ]
  }
}

 

The “Incident vs. Service Request” field is not the field I'm updating. I assume there some is configuration that is making this field required when updating a ticket, although I can't figure out what that config might be? The field has “Required to solve a ticket” enabled, but I'm not trying to solve a ticket, and there are other fields with this setting which don't cause the same problem. Can anyone help me out?

 

Thanks.

 


0

12

12 comments

Hi Mark, 
 
So you would have to set the conditions of that custom ticket field to exceed the needs/priority of your other required fields. 
 
The Update Ticket API is strict on following any ticket rules. Basically when a request is made to the update ticket API all of the rules set for a ticket are run and if something is missing it won't allow the update to take place. The difference between a ticket field being checked as required and a trigger for a ticket field is that the trigger is looking for very specific conditions to be met. 
 
This is what I would do: let's say you have 4 required ticket fields (A, B, C, D). Two of those custom ticket fields (C & D) are what you want to populate at ticket creation. However, because A & B are also required, the update won't go through. 
 
What you'll do then is for A & B you'll uncheck Required to solve ticket for both of those. Then you'll create a trigger for A & B that specifically prevents the ticket from being closed without those fields being present. 
 
That way you can successfully pass data to the Update Ticket API to ticket fields C & D at ticket creation. 
 
So if you set a check to see if the other required fields are present specifically when a ticket is trying to be closed then the only rule for those fields that Update ticket API will stop for is when the ticket status is being set to closed. It should allow you to update the ticket at creation for those custom fields your passing data to. 
 
 

0


Erica Girges thanks, but I'm not sure you've understood my actual issue. Let me clarify.

1. Agent opens a ticket

 

2. Sidebar app loads immediately

 

3. Sidebar app queries an external API with the requester's email address and receives some extra data about the requester. We now want to save this straight back to the ticket in custom fields.

 

4. Sidebar app tries to save this extra data back to custom fields ( i.e. by sending a PUT request to /api/v2/tickets/<ticketid>.json with the body like this


{
  "ticket": {
    "custom_fields": [
      {
        "id": "27609430851869",
        "value": 661
      },
      {
        "id": "27609398553885",
        "value": "Some data"
      },
      ... etc
    ]
  }
}

 

5. Sidebar app receives 422 Unprocessable Content error with the following body:

{
   "error": "RecordInvalid",
   "description": "Record validation errors",
   "details": {
       "base": [
           {
               "description": "25 - Incident Vs Query : needed",
               "error": null,
               "ticket_field_id": 27690247974045,
               "ticket_field_type": "FieldTagger"
           }
       ]
   }
}

 

All this happens in the first few seconds after opening a ticket. So it's impossible to populate any custom fields on a ticket until the ticket has been submitted by the agent with all required fields completed, even if those custom fields are not required themselves.   

0


Hmm that's strange. I'm going to attach it again but in case you're having issues opening it, I will also share this google drive link which you can also use to access it. 

0


Erica Girges  thanks for your reply. I don't see a screen recording though?

0


Unfortunately, if there are any other unpopulated required fields when making a ticket update those would have to be included. 
 
However, you shouldn't need to utilize additional apps to ensure this field gets populated. You would just need to add a trigger which would make this field conditional and would prevent the ticket from closing without. 
 
I've attached a screen recording to demonstrate what it looks like to the agent with this trigger in place. Even if all of the other required fields are populated the agent can not set the status to solved until that specific field is populated.
 
For the trigger you would just set your conditions to if that ticket field value is missing and the ticket status is changed -> then the action would be to set the status to open. 
 
This will alert the agent of the error and force the ticket status to stay open until the field is completed the field.
 

0


Erica Girges  this is not what is happening. There is a field that is required for submitting a ticket. However I am trying to update a completely unrelated field and I am not trying to submit the ticket. It seems that you can not make any updates to any custom fields on a ticket whilst there are other required fields that are not completed.  This seems like a bug to me.

 

Narendra Pande, Hrishikesh  I have found very roundabout way to solve the issue. My API request is coming from a sidebar app. There is a ‘ticket.submit.done' event that is fired when the ticket is submitted. At this point we know that all required fields must have been completed, so we can then update any custom fields by listening to this event. When I tried this initially it did work, however if the agent has the option selected to close the ticket on submit, the ticket is closed before the field can be updated, so the update never completes. This seems like another bug to me - but I found a horribly complicated work around. I created a secondary app running in th “background” location. This app runs constantly, even when I ticket is closed. So now my sidebar app still listens to the ticket.submit.done event, but instead of updating the custom field directly, it triggers another event in the background app with the required data. The background app then updates the custom field and will still work even if the ticket closes before the update has happened.

0


Hello Hrishikesh, 
 
Typically when we see a validation error like this, it's due to the custom ticket field being tied as a condition for another ticket field. An example would be if ticket field ABC includes "specific text" then ticket field XYZ must have a specific value. This would mean that when you submit a request to Update the ticket field ABC you must also update XYZ since it is conditional upon that. 
 
I would recommend looking over your ticket field conditions to see if that could be the case. 
 
If you determine that there are no conditional conflicts definitely let us know and we can take a closer look for you.

0


Hi 8329089691546 , we're facing exact same issue as you. Were you able to solve the issue ?

0


Hi Mark,

Thank you for the additional information.  It's a bit hard to know what the issue might be without seeing the entire request and knowing the set up in the account, but maybe we can still help.  Are you able to share across the API request you are making?  Also, do you have other requests set up that are working?

0


1263213579849 no I haven't been able to resolve it. I'm not updating a drop-down field. Just a custom field with a free text value. The custom field needs to be updated as soon as the ticket is opened, but I can't update it due to this validation error message. The field is only conditional on the ticket being submitted, but I'm not trying to submit the ticket, merely update a custom field. 

0


Sign in to leave a comment.

Didn't find what you're looking for?

New post