- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 07:04 AM
in table table form after state moved to Resolved need to closed the state as close after 30 days, how can i achive ,
i need to use schedule job or what,
any one provide me the solution or souce code for this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 07:07 AM - edited 04-05-2024 07:09 AM
You can write a schedule job which runs on a daily basis, below is the sample script you can use:
// Find records in the table where state is "Resolved" and resolved date is more than 30 days ago
var gr = new GlideRecord('your_table_name');
gr.addQuery('state', 'resolved');/ /replace with resolved backed name
gr.addQuery('resolved_date', '<', gs.daysAgoStart(30));
gr.query();
while (gr.next()) {
// Update state to "Closed" and perform any additional actions if needed
gr.state = 'closed'; // replace with closed backed name
gr.update();
// Log the updated record
gs.info('Closed record ' + gr.getDisplayValue() + ' which was resolved more than 30 days ago.');
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 07:07 AM - edited 04-05-2024 07:09 AM
You can write a schedule job which runs on a daily basis, below is the sample script you can use:
// Find records in the table where state is "Resolved" and resolved date is more than 30 days ago
var gr = new GlideRecord('your_table_name');
gr.addQuery('state', 'resolved');/ /replace with resolved backed name
gr.addQuery('resolved_date', '<', gs.daysAgoStart(30));
gr.query();
while (gr.next()) {
// Update state to "Closed" and perform any additional actions if needed
gr.state = 'closed'; // replace with closed backed name
gr.update();
// Log the updated record
gs.info('Closed record ' + gr.getDisplayValue() + ' which was resolved more than 30 days ago.');
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 10:38 AM
HI @Maddysunil ,
Thanks for your reply,
with if condition we willa check and achive right, like this
var rd=gr.getValue('resoved_date');
var days=gs.daysAgoStart(30);
//var days=gs.daysAgo(30);
if(rd <30)
{
//logic
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 07:34 PM
If you are suing this line
gr.addQuery('resolved_date', '<', gs.daysAgoStart(30));
then no need of checking in if , But if you are not using above line then inside while loop you can use if.