updating a field by scheduled job

newbiedeveloper
Giga Contributor

Hi All

I wrote a scheduled job to update a field. It showed that the count is 15400. But it didnot update around 600 records. When i filter the records i frontend, it shows 15400. How come count is showing correct in log but 600 records didnot get updated.

I again re-run the scheduled job and it said it updated 600. But when i saw those records didnot show any updation of that field.

What could be the possible cause?

24 REPLIES 24

BALAJI40
Mega Sage

share your code, which you run?


//record not updated since last 2 years



function Check(){


   


var gr = new GlideRecord('cmdb_ci');


      gr.addEncodedQuery("install_status=1^ORsys_updated_on<javascript:gs.dateGenerate('2014-08-01','00:00:00')");


      gr.query();  



  while(gr.next())


    {                  


                     


                    gr.u_date = 'Retire';         //u_date is a string field


                    gr.update();


            }


      gs.log("Executed "+ gr.getRowCount()+ " records.");



              }



      Check();


Run in background script,


var gr = new GlideRecord('cmdb_ci');


      gr.addEncodedQuery("install_status=1^ORsys_updated_on<javascript:gs.dateGenerate('2014-08-01','00:00:00')");


      gr.query();


gs.print( gr.getRowCount());



first check weather row count of front or back end same or not. Then we can after update all the records.


Hi Balaji



Its showing correct count using the above script in Background script.