How to get specific journal entry (Additional Comments & Work Notes)?

Jehiellb
Giga Contributor

Hi Team,

Is there a way to capture a specific Additional Comments & Work Notes? I'm doing an integration where I'm sending an incident ticket to another platform using REST API: POST and PUT method and a Business Rule. But there is a case that if I update the ticket all the comments is being posted even tho I already receive it from the previous update.

I'm somehow familiar with journal entry but not fully knowledgeable to use it, I know that

getJournalEntry(1) gets the latest entry.
getJournalEntry(-1) gets all entries.

I have tried using the both of them, but what I need to get is the journal entry in between.

For example: 

I created an Incident and assigned it to Group 1 then posted a comments and work notes. This update will be posted to another platform that I'm using. 
Additional Comments 1-3
Work notes 1-3

Then, I reassigned the incident to another group - (Group 2) then posted another comments and work notes. This update should not be captured  b/c I have a business rule condition that it will only update the ticket from the other platform WHEN the Assignment group is assigned to Group 1.
Additional Comments 4-6
Work notes 4-6

Lastly, I reassigned it back to Group 1 and check the updates from the other platform. It did capture the
Additional Comments 4-6
Work notes 4-6 
BUT also the 
Additional Comments 1-3
Work notes 1-3

 

What I want to capture is only the 
Additional Comments 4-6
Work notes 4-6
not the 1-3, b/c it was already posted from the previous update.

 

Would that be possible? Let me know if you need any clarification to help you answer my question. I will provide information if necessary.

 

Your help on this will be much appreciated, Thanks in advance!  

 

5 REPLIES 5

DrewW
Mega Sage
Mega Sage

You can just go to the sys_journal_field table and query for the information you are looking for.

 

Prerana1
Kilo Guru

Hye did you achieve this?

 

If so can you please share the solution, i am also having the same query.

 

Thanks

-O-
Kilo Patron
Kilo Patron

It is possible to get all history data using the GlideSPScriptable object/API; e.g.

var stream = new GlideSPScriptable().getStream('incident', 'ff4c21c4735123002728660c4cf6a758');

gs.debug(JSON.stringify(stream, null, '\t'));

executed in Scripts - Background, in a PDI, prints out:

{
	"display_value": "INC0007002",
	"sys_id": "ff4c21c4735123002728660c4cf6a758",
	"short_description": "Need access to the common drive.",
	"number": "INC0007002",
	"entries": [
		{
			"sys_created_on_adjusted": "06.06.2021 01.25.48",
			"sys_id": "562a9bb52f28fc50c6ba2ca62799b6e0",
			"login_name": "System Administrator",
			"user_sys_id": "6816f79cc0a8016401c5a33be04be441",
			"initials": "SA",
			"sys_created_on": "2021-06-05 22:25:48",
			"contains_code": "false",
			"field_label": "Additional comments",
			"name": "System Administrator",
			"value": "Wroker added an additional comment",
			"element": "comments"
		},
		{
			"sys_created_on_adjusted": "17.10.2018 08.48.24",
			"sys_id": "930a1bb52f28fc50c6ba2ca62799b677",
			"login_name": "System Administrator",
			"user_sys_id": "6816f79cc0a8016401c5a33be04be441",
			"initials": "SA",
			"sys_created_on": "2018-10-17 05:48:24",
			"contains_code": "false",
			"field_label": "Work notes",
			"name": "System Administrator",
			"value": "Updated the priority of the Incident.",
			"element": "work_notes"
		},
		{
			"sys_created_on_adjusted": "17.10.2018 08.48.24",
			"sys_id": "d30a1bb52f28fc50c6ba2ca62799b677",
			"login_name": "System Administrator",
			"user_sys_id": "6816f79cc0a8016401c5a33be04be441",
			"initials": "SA",
			"sys_created_on": "2018-10-17 05:48:24",
			"contains_code": "false",
			"field_label": "Work notes",
			"name": "System Administrator",
			"value": "Work note copied from Parent Incident: Updated the priority of the Incident based on the criticality of the Incident.",
			"element": "work_notes"
		}
	],
	"user_sys_id": "6816f79cc0a8016401c5a33be04be441",
	"user_full_name": "System Administrator",
	"user_login": "admin",
	"label": "Incident",
	"table": "incident",
	"journal_fields": [
		{
			"can_read": true,
			"color": "green",
			"can_write": true,
			"name": "comments",
			"label": "Additional comments"
		},
		{
			"can_read": true,
			"color": "red",
			"can_write": true,
			"name": "work_notes",
			"label": "Work notes"
		}
	]
}

basically everything that has happened in a JSON.

Though you should always send just the journal entry of the current update and do the filtering, well in the filter of the BR that sends the update: make it not run when updated should not be sent.

Bharat28
Tera Contributor
Hi Jehiellb

Could tell me how did you achieve this i'm having same query to fetch additional comments in target instance 

 

Thanks