Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to retrieve comments for an incident via the rest api

jsamm
Giga Contributor

When using the rest api for incidents, the "comments" journal field always returns an empty string.   Setting "sysparm_display_value = true" will output all of the comments in a single string which is not very useful.   How do I query the journal table for the comments as separate json objects?

1 ACCEPTED SOLUTION

ChrisBurks
Giga Sage

Use the rest api for the sys_journal_field table in the same manner you would query the incident table providing the desired criteria. In this case you're looking for the "comments" from an incident record. So you would set the endpoint to point to the sys_journal_field and provide the incident sys_id that you're looking to gather the comments from as well as set to limit the query to the comments field (because you can gather the work_notes as well if desired)



{your instance name}.service-now.com/api/now/table/sys_journal_field?sysparm_query=element=comments^element_id={your incident sys_id   goes here}


That should give you a result of the comments from a specific incident each as a separate item.



Table API - ServiceNow Wiki


View solution in original post

5 REPLIES 5

kinda late but hopefully it'll help people in the future:

glide.ui.permitted_tables system property (navigate to sys_properties.do?sys_id=c3dee8670a0a0aa70064b48de5ad973e on your instance)