How custom tickets fields and inject Javascript in window ticket

I’m trying a solution via API to update the visibility of a selected ticket field, hiding it from the ticket screen. However, with the APIs I tried, I couldn’t find a solution.

For this I am trying to use the following API: [PUT] /api/v2/admin/ticket_fields/[ticket_fields_id]

Searching, I managed to locate this variable that in theory hides the item from the portal, but when I run this command, it returns an error in the request, so I believe I must be doing something wrong when sending this JSON.

{
“visible_in_portal”: false
}

I’ve also tried using this object, but I wasn’t successful either:

{
“visibility”: {
“agent”: false,
“customer”: false
}
}

Another API I also tried was options: [PUT] /api/v2/admin/ticket_fields/[ticket_fields_id]/options

However, when running I also get a 404 error return, so I believe that this request no longer exists in this current version.

{
“options”: [
{ “value”: “Option1”, “label”: “Option 1” },
{ “value”: “Option4”, “label”: “Option 4” }
]
}

{
“options”: [
{ “value”: “option1”, “label”: “Option 1”, “visible_in_portal”: true },
{ “value”: “option2”, “label”: “Option 2”, “visible_in_portal”: false },
{ “value”: “option3”, “label”: “Option 3”, “visible_in_portal”: true }
]
}

Has anyone ever had to develop something similar to this?

And I would also like to know how to inject javascript code into a ticket page to manage ticket field tabs.

Hey @Kevin_Neri

what exactly is your usecase?
Would help to understand, why you try to hide the ticket field.

Hiding an existing ticket field for agents is only possible in the ticket view, as far as I know.
You could write a custom app and use the following: Freshworks Developer Docs | Use interface methods

Or maybe the marketplace app Hide Fields already does the trick for you.

But you need to be aware that this would work only in ticket details page as mentioned.
So you will still be able to see the field in the list view and you could also do “bulk updates” on that field.

A similar thing as mentioned above can be done in the portal to hide the field from portal user’s eyes: Freshworks Developer Docs | Build secure end-user apps

Hope that helps for a start.

Best
Tom

This is an example of what we are trying to implement, in this case we want to be able to hide this marked item from our filed ticket (“My Test hide”).

We are trying to find a solution via API, but with the tests carried out we were unable to obtain a result in accordance with what we expected, we were only able to delete the item, but hiding it still did not provide a solution.

For this we are using the API: [PUT] /admin/ticket_fields/${selectedTicketFieldId}

choiceValueId → ID of (“My Test hide”) mentioned in the print

const date = {
label: selectedTicketField.label,
label_for_customers: selectedTicketField.label_for_customers,
choices: selectedValues.map((choiceValueId) => {
return { deleted: true, id: choiceValueId };
})
};

This way, we are deleting the selected item from the ticket field, but what we are looking for is to hide this item without deleting it. This is because this action is not permanent, we constantly need to disable items from the lists.

But when we tried to use other endpoints to try to hide this value from the list, we were unable to find a solution that suited us.

Hey @Kevin_Neri

thank you for the clarification - So you don’t wanna hide a complete ticket field (which would be possible as explained), but choices from a dropdown?

As you wrote, using the ticketfield API would affect the ticket field (resp. the specific choice) as a whole.
Which means

  1. The value is removed from all tickets, which do have this value set
  2. It is permanent and for all agents, so it does not make sense if you just want to hide it depending on the ticket
  3. Deleting the choice when you already are inside the ticket details page, would be to late - You would need to refresh the page to make the change visible.

But there is the option to hide specific choices.
So here’s the link to the documentation: PROPERTIES widget fields

It first explains how to show/hide and enable/disable a whole field.
And if you scroll down, you’ll see how to set a specific value or how to set the available options (your described usecase).

Again it needs to be mentioned, that hiding a specific option (as well as a whole field) does only work inside the ticket details page.
So you still would be able to set the option via bulk update (in listview) or by creating a scenario or by setting it via automation.

Hope that helps.

Tom