deleted deleted

deleted deleted   •   about 8 years ago

issues with coments

am trying to read a single comments on id 5, but am having issues with the script below.

$(document).ready(function(){

var card = new SW.Card();
var helpdesk = card.services('helpdesk');

helpdesk.request('tickets',5).then(function(data){

$.each(data.tickets, function(index, ticket){

$('body').append('commentid' + ticket.comments.id + 'body' + ticket.comments.body);

});
});

});

Can you correct that. thanks

  • 3 comments

  • Manager   •   about 8 years ago

    So two issues:

    1) In order to read ticket comments, make sure you have the Extended Data Access for the Helpdesk API turned to ON in your app settings.

    2) In your API request, it needs to be request('ticket', 5) not 'tickets'. This will return a single ticket object, so you can remove the 'each' loop.

  • Manager   •   about 8 years ago

    Yes, except for 'tickets.comments.id'. If you want the first ticket comment you need 'tickets.comments[0].id' and 'tickets.comments[0].body'. Otherwise, you can loop over the list of comments, 'ticket.comments'.

  • Manager   •   about 8 years ago

    I should have said 'ticket.comments[0]' not 'tickets'. How many comments are on the ticket? There may only be two, so [2] would not exist.

Comments are closed.