I will start by saying I’m outside of my depth here - I’m not a JS guy at all. I’m a C# guy - so this could easily be me, but I don’t think it is.
I am trying to get the Ticket ID that is displayed to the user. Eg, if they are working on ticket #1234, I want to receive 1234. Then, I’m trying to pad it to a total of 10 digits, so there will be some leading 0s to get it there (at least for now). However, I’m getting some random number. According to the documentation, I believe I should be getting the display_id instead, but when I call that, I simply get an empty value.
you are mixing F-Service and F-Desk @vangakirankumarreddy.
The request is on Freshservice, you are on Desk.
@mbutler756, did you log the whole data.ticket object?
If not, you may find the number you are looking for in there.
I am not into Freshservice. I tried to understand the API documentation, but I was not able to figure out, which field you need.
So maybe you could log the whole data.ticket object and look for the number???
Another option would be to just use the browser for getting the ticket data.
If you call https://yourdomain.freshservice.com/api/v2/tickets/[id], you should get the JSON and search for the [id].
Works in Freshdesk, hopefully in Service too.
Thanks Vanga. I have tried both ‘’‘id’‘’ (what I’m currently using) and ‘’‘display_id’‘’
Oddly enough…I just used ‘’‘display_id’‘’ again and it’s working – I guess I was doing something wrong the first time, but the value is displaying properly!!! Thank you.
I modified the code just slightly to pad ‘’‘TKT#’‘’ to the front when the length of the ‘’‘ticketId’‘’ variable is < 10 chars. That’s not displaying at the moment, but I should be able to troubleshoot that (unless you see something glaringly obvious).
‘’’
document.addEventListener(‘DOMContentLoaded’, function() {
app.initialized().then(function(_client) {
window.client = _client;
_client.events.on(‘app.activated’, function() {
_client.data.get(‘ticket’).then(function(data) {
var ticketId = data.ticket.display_id;
var formattedTicketId;
Just a quick note - this was my first post here and my first foray into JS. Thank you so much for the assistance you have given me - such a great community of devs. Thank you for the assistance and kindness you have shown. JS is not my forte
I was able to resolve this. It turns out that the length property is only available to a string. Once converting my variable to a string - everything worked as expected.
Thank you for your help and assistance! I truly appreciate the community and the advise you have shared with me!