Get incident category , state and priority of incidents that have work notes with specific keywords

Snehal13
Kilo Sage

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.

6 REPLIES 6

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

Community Alums
Not applicable

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.