can you pull comments/worknotes for certain state that ticket was in ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 04:50 AM
Hi,
im looking for a way to programmaticaly check what comments / worknotes incident had in certain state.
Example - state new - user adds 2 comments.
state - in progress - user adds 3 comments.
etc.
I can ofc query sys journal field table where i match sys_id of incident but here i get all entries for the whole life cycle of incident. Im specifically curious in entries only when incident was in certain state.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 04:59 AM
Hi,
This is not straight forward and I would recommend not query the journal table also here, it may have some negative impact on the performance.
What is the story behind this? What is the Use case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 05:04 AM
Hi @PetMat,
are you looking for a report count or your looking for a perticualr static incident ?
if your looking for reporting and analysis then its not recommend to go that way. this will cause perfomance hit alternatively you can create a before insert business rule which updates the comments/notes along with the current state of incident.
this will let you know what comment was added on which state...
AND>
if your looking for 1 or few static incidents the you can try the below script:
var incidentSysId = 'YOUR_INCIDENT_SYS_ID';
var desiredState = 'New';
var journalGr = new GlideRecord('sys_journal_field');
journalGr.addQuery('element_id', incidentSysId); // incident sys_id
journalGr.addQuery('element', 'incident');
journalGr.addQuery('field', 'comments');
journalGr.addQuery('new_value', desiredState);
journalGr.query();
while (journalGr.next()) {
var entrySysId = journalGr.getValue('sys_id');
var entryValue = journalGr.getValue('value');
var entryTimestamp = journalGr.getValue('sys_created_on');
gs.info('Entry Sys ID: ' + entrySysId + ', Value: ' + entryValue + ', Timestamp: ' + entryTimestamp);
}
I hope this helps...
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 05:07 AM
We have an integration going between 2 instances of serviceNow (custom solution, not Out of the box). and there are certain statuses prior the integration starts (customer may have entered comments in those states). And if conditions are met and integration starts they want to send comments over to us that they have entered in certain states (not all) before integration started.