Using Table API, is it possible to fetch the last updated 'Additional comments'?

Suggy
Giga Sage

Using Table API/Rest API is it possible to get the last updated comments?

 

PS - I see few posts talking about querying sys_journal_field table, but I dont want to go via that approach as I believe its not recommended to query such large tables, sorting on large tables etc

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Suggy 

not possible with Table API as journal entries are stored in sys_journal_field table

You can use Scripted REST API and then get the latest comments and send as API response

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

TaironeA
Tera Expert

Getting Last Updated Comments via Table API/REST API

By default, comments (work notes, additional comments, etc.) are stored in the sys_journal_field table. However, querying it directly can be inefficient due to its large size and sorting requirements.

Alternative Approaches

Use the Parent Record's 'comments' Field (If Available)

  • Some tables (like incident, task) store the most recent comment in a field like comments or work_notes.
  • You can retrieve it using a GET request to the Table API:
    GET /api/now/table/incident?sysparm_fields=sys_id,number,comments
    • Replace incident with the required table.
    • This method works only if comments are stored within the main record.

2️⃣ Leverage the ‘sys_updated_on’ Field for Filtering

  • Instead of querying sys_journal_field, you can fetch records based on sys_updated_on to get the most recently updated records:
    GET /api/now/table/incident?sysparm_query=sys_updated_on>=javascript:gs.daysAgoStart(1)&sysparm_fields=sys_id,number,sys_updated_on,comments
    • This retrieves records updated in the last day, including any comment updates.

Use a Scripted API (If Customization is Allowed)

  • If default Table API doesn’t meet your needs, a scripted REST API can be created to return only the latest comment without querying the entire sys_journal_field table directly.

Key Considerations

🔹 Querying sys_journal_field is not recommended for frequent calls due to performance issues.
🔹 If comments are critical for your integration, consider storing the latest comment in a separate field (via business rules) for easier retrieval.

Hope this helps! Let me know if you need more details.

(If this was helpful, don’t forget to give a thumbs-up! )

Suggy
Giga Sage

Anyone?

Ankur Bawiskar
Tera Patron
Tera Patron

@Suggy 

not possible with Table API as journal entries are stored in sys_journal_field table

You can use Scripted REST API and then get the latest comments and send as API response

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Suggy
Giga Sage

With table API, we can get ALL the comments and worknotes but not just the latest one is it? @Ankur Bawiskar