Get incident category , state and priority of incidents that have work notes with specific keywords
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 07:37 AM
I need incident category , state and priority of incidents that have work notes updated as either of "Executed script" or "Deployed script"
Currently, I am querying Table - sys_journal_field and filters as Element = work notes, name is incident
value is 'executed script' OR value is 'Deployed script' but it gives element id and total records but is half of my expectation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 07:34 AM - edited 09-11-2024 03:06 PM
Database views do not support "CONTAINS", see:
AddATableToTheDatabaseView.html
You can do that in a script:
var sjf = new GlideRecord('sys_journal_field');
sjf.addEncodedQuery('name=incident^element=work_notes^valueLIKEExecuted script^ORvalueLIKEDeployed script');
sjf.query();
//gs.info("Found " + sjf.getRowCount() + " records");
while (sjf.next()) {
var inc = new GlideRecord('incident');
inc.addQuery('sys_id', sjf.element_id);
inc.query();
if (inc.next()) {
gs.info('inc: ' + inc.number + ', Category = ' + inc.category.getDisplayValue() + ', state = ' + inc.state + ', priority = ' + inc.priority);
}
}
However, you can modify the where clause of the database view:
sjf_element='work_notes' && sjf_name='incident'
and filter the results using
Value, Contains, executed script
OR
Value, Contains, deployed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 08:27 AM
You can try achieveing this in flow designer, less technical debt by maintaining a long script. You can output the incidents in a log at the end of the flow to view the results or view the execution details.