Creating comments on an Incident via the REST API

bscharm
Kilo Explorer

I am trying to add to the comments on an incident via the REST API, but can not clearly see how to do this. If I post a new incident and add to the "comments" field, it does not persist. Does anyone know of a way to do this? Thanks.

1 ACCEPTED SOLUTION

Hi Brad - did you actually check the incident that was created? The example page does work. What you are seeing in the response is because of the nature of the Comments and Work notes fields. They don't actually store the comments you put in an incident, so when the response says: comments: "" - that should not be taken as there are no comments for that incident.



What happens is when you post to the comments field, it is then stored over in the sys_journal_field table with a relationship back to the incident. The activity formatter on the incident form goes and retrieves all the comments (and other field you tell it too) and presents them on the form in date order. The trick to getting the comments back via the GET - is adding &sysparm_display_value=true which they do actually have in the screenshot, but don't state it (that I noticed).



Let me know if this doesn't make sense.


View solution in original post

11 REPLIES 11

Hi, and how can I change the name of the person who make the additional comment:


2016072003.PNG


manish123
Giga Guru

Hi All,



I have a similar type of REST setup in Eureka version and its working except for additional comments & work Notes. And I am trying to convert these Journal Inputs entries to String and placed it in String field in import set staging table. Below is line of code:-



var comm= inc.comments.getJournalEntry(-1).toString();  


comm=comm.replace(/["']/g, "");  


comm=comm.replace(/[\n*]/g, "");      


comm=   String(comm);



r.setStringParameter('u_additional_comments',comm);


gs.log('Comments :' + comm);



But its appearing as blank. However, on log its prints properly.I also tried by passing the hardcoded value through content type and that was working.


Any idea where its getting wrong and what?