How to check if a comment or work notes exists on a record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2019 09:19 AM
I'm trying to pull comment data from a third party app via REST and insert it into incident records in snow and I was wondering how to update the activity stream with new comments. Currently, when creating a record I will just set the comment I got from the third party app. But if I wanted to update the record and see if any new comments were made in the third party app, I figured I would have to query the sys_journal_field table and check to see if the comment already exists and if it doesn't I should update the activity stream with my new comments I read that querying the sys_journal_field table could be overkill since it could have so many entries. Is this the correct way of doing things or is there a better way?
Example of what I'm doing:
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('value', responseObj.Response.ListOfServiceRequest.ServiceRequest[i].ListOfLa311ServiceRequestNotes.La311ServiceRequestNotes[k].Comment);
gr.query();
if(!gr.next()){
gr.comment = responseObj.Response.ListOfServiceRequest.ServiceRequest[i].ListOfLa311ServiceRequestNotes.La311ServiceRequestNotes[k].Comment);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2019 11:13 AM
Shouldn't it be?
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('value', responseObj.Response.ListOfServiceRequest.ServiceRequest[i].ListOfLa311ServiceRequestNotes.La311ServiceRequestNotes[k].Comment);
gr.query();
if(!gr.next()){
gr.value = responseObj.Response.ListOfServiceRequest.ServiceRequest[i].ListOfLa311ServiceRequestNotes.La311ServiceRequestNotes[k].Comment);
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2019 11:13 AM
Hi Brianlion,
You can GlideRecord the target Table (for ex: Incident) to fetch work notes or comments and then apply the logic to do the matching check.
gr.comments.getJournalEntry(-1);
gr.work_notes.getJournalEntry(-1);
Reference:
-Pradeep Sharma