Trouble retrieving sys_id after posting comments via REST API

Swapnijain001
Kilo Contributor

Hey everyone,

 

I’m running into a bit of a problem while trying to post comments to incidents using the REST API in ServiceNow. I’m able to update the comments or work_notes field just fine, and the comment appears correctly on the ticket. However, I need to retrieve the sys_id of that exact comment from the sys_journal_field table right after posting — and that's where I'm stuck.

 

The usual approach of filtering sys_journal_field by element_id and ordering by sys_created_on DESC isn’t reliable enough. In high-activity environments, other updates might be logged almost simultaneously, and I end up grabbing the wrong entry.

 

Is there a reliable way to get the sys_id of my comment immediately after posting it via API? I was thinking of embedding a unique token in the comment body, but I’m wondering if there’s a cleaner or more robust solution.

Has anyone else faced this issue or found a good workaround?

0 REPLIES 0