display number of open Change Tasks

Riaz3
Giga Expert

Hi,

I would like to display a number on the change form which shows the number of open change tasks for that change.

The field will be a String called Open Tasks.

Does anyone know how to do this or has a script which would display this on the Change form?

Thanks

10 REPLIES 10

This does not seem to be sufficient. Such a business rule would only be triggered when a Change Request is updated. It would not update the counter when a Change Task is added or completed.

Yes, that is true

Yes Slava has a correct point, So in that scenario we can add After Insert/Update Business rule on change_task table which will update the change_request field whenever a new change_task is added or closed.

Please find the Script Below:

(function executeRule(current, previous /*null when async*/) {
	var gr= new GlideRecord('change_task');
	gr.addActiveQuery();//query only active change task
	gr.addQuery('change_request',current.change_request);//query change task with same parent change request
	gr.query();
	updatecount(gr);
})(current, previous);
function updatecount(gr){
	var gr2 = new GlideRecord('change_request');
	gr2.get(current.change_request);//get the parent change request
	if(gr2.isValidRecord()){
		if(gr2.field_name.toString()!=gr.getRowCount()){//validates if the active count is not same
			gr2.field_name=gr.getRowCount();//sets the row count in change request
			gr2.update();
		}
	}
}

Is there any update on this? If I was able to resolve the issue could you please mark my answer as Correct and Helpful based on the impact.

Hi Alok,

That is a good question. We have some Standard changes with a lot of tasks, having a field to show the number would allow easy identification of how many are open, set up triggers and alerts and allows a number to be visible in a List.