Auto update field values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 03:49 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 04:06 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 04:16 AM
yeah i have made , but i need to do in schdeuled job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 04:27 AM
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();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 01:39 AM
Hi
You can do this in flow designer with no need to write any scripts. Better approach than using workflow