- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2023 07:32 AM
Hi
Is it possible to put a req item ticket on-hold until a date, such as if someone raises a leaver request but they're not leaving until 2 weeks time, we can put that ticket on hold until the end date, then the ticket automatically comes off hold on that date and back to open state.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2023 08:07 AM
Hello Lee,
There are multiple ways to achieve this, I will share one of the solutions which will surely help you.
You can use a Scheduled Job to run the script regularly and check if the "end date" has passed.
var request = new GlideRecord('sc_req_item');
request.addQuery('active', true);
request.addQuery()// Add needed query over here so it will only fetch the required ritm's
request.query();
while (request.next()) {
var end_date= request.variables.end date; //Please check the variable name
var currentDate = new GlideDateTime();
if (end_date.compareTo(currentDate) >= 0) {
request.state = '6'; // On Hold state
request.update();
} else {
request.state = '1'; // Open state
request.update();
}
}
This is just the logic, please alter the script as per your requirement.
Regards
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2023 08:07 AM
Hello Lee,
There are multiple ways to achieve this, I will share one of the solutions which will surely help you.
You can use a Scheduled Job to run the script regularly and check if the "end date" has passed.
var request = new GlideRecord('sc_req_item');
request.addQuery('active', true);
request.addQuery()// Add needed query over here so it will only fetch the required ritm's
request.query();
while (request.next()) {
var end_date= request.variables.end date; //Please check the variable name
var currentDate = new GlideDateTime();
if (end_date.compareTo(currentDate) >= 0) {
request.state = '6'; // On Hold state
request.update();
} else {
request.state = '1'; // Open state
request.update();
}
}
This is just the logic, please alter the script as per your requirement.
Regards
Prasad