Auto update field values

devservicenow k
Tera Contributor

My requirement is to Auto update field values after 5 days of creation.

Record is created--> after 5 days --> short_description (" alert 5 days) field should be auto updated.

how to do this in Schdeuled job?

8 REPLIES 8

suvro
Mega Sage
Mega Sage

Create a workflow on that table and it should run on insert

 

In the worklow use a timer activity to wait for 5 days 

then use set value activity to set the necessary field with desired value.

yeah i have made , but i need to do in schdeuled job.

Use this


   var actualDateTime = new GlideDateTime();
  

   var gr = new GlideRecord('table_name');
   gr.addActiveQuery();
   gr.query();
   while(gr.next()){
      var dur = new GlideDuration();
      var updatedOn = new GlideDateTime(gr.sys_updated_on);

 dur = GlideDateTime.subtract(updatedOn , actualDateTime );

     dur = dur.getDaysPart();
      if(dur >= 5){
         gr.short_description = "YOur short description";

         gr.update();
      }
   }

eagle18
Tera Contributor

Hi @devservicenow k 

You can do this in flow designer with no need to write any scripts. Better approach than using workflow

Flow Designer Wait Condition

find_real_file.png