Delete historical scores from indicators

oana5
Giga Contributor

Hi everyone,

We have some indicators created before go-live and we would like to have these scores deleted for the period before go-live, because otherwise the trend is biased.

Do you happen to know a way of doing this, other than manually (it wouldn't be a problem if it wouldn't take too much time)?

Best regards,

Oana

2 REPLIES 2

User205728
Tera Expert

Hi Oana,



You can use a script to delete the data. I suggest using a scheduled job to run the script or else you risk timing out. Something like the below could work:



//delete records. Make sure to test the count first and make sure that you are querying the correct records then outcomment the delete command


deleteRec();


function deleteRec() {


          var rec = new GlideRecord('pa_scores');


          rec.addQuery('start_at','<', 20151001); // This deletes all data from before the date value.


          rec.query();


          var count = 0;


          while(rec.next()){


            //gs.print(rec.name);


            count++;


          }


          gs.log('Scheduled Job: Delete PA Scores will delete ' + count +' records.'); // Run with this line before actually outcommenting the last line of code.


          //rec.deleteMultiple(); // Enable this line when the desire amount is returned in the script log above.


}


User356215
ServiceNow Employee
ServiceNow Employee

I accomplished a historical cleanup using the following method. 

1. Add a condition to your Indicator with a condition that will never return true (i.e. Active=true AND Active=false)

find_real_file.png

 

2. Create a new Job.

  • Score operator=Fixed
  • Score fixed start=On or before the day you started collecting data
  • Score fixed end=Day before you went live
  • Run=On Demand
  • Associate your Indicator with the Job

find_real_file.png

 

3. Hit Execute Now and wait for the job to complete. Continue to step 4.

find_real_file.png

4. REMOVE the conditions you added to your Indicator.