Trying to list Incidents in standard report via script.

Aditya Dev
Kilo Contributor

Hi All, I am trying to fetch data on standard report (list view) using script include.

Below is scenario : 

There are two custom fields on Incident form (value - integer)

1. actual efforts (u_actual_efforts)

2. planned efforts (u_planned_efforts)

I want to fetch data comparing these two fields ; if actual efforts is more than planned efforts return incidents.

Can you please help me how to write script for the same? I want to use script Include.

Also, if there is any other way, i would also prefer using it.

 

1 ACCEPTED SOLUTION

Hi Aditya,

 

Use the following script include;

var CommunityAnswerEffortComparison = Class.create();
CommunityAnswerEffortComparison.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	compareEfforts : function(){
		var array = [];
		
		var gr = new GlideRecord('incident');
		//gr.addActiveQuery();
		gr.query();
		
		while(gr.next()){
			
			var plannedEffort = gr.getValue('u_planned_efforts');
			var actualEffort = gr.getValue('u_actual_efforts');

			var difference = gs.dateDiff(actualEffort, plannedEffort, true);

			if(difference < 0)
				array.push(gr.getValue('sys_id')+'');	
		}
		
		return array.toString();
		
	},

    type: 'CommunityAnswerEffortComparisonForReport'
});

 

Hopefully this will fulfill your requirement.

 

View solution in original post

5 REPLIES 5

Aditya Dev
Kilo Contributor

Thanks 

Muhammad Khan, this really helps ! Code worked absolutely fine