Is it possible to put a ticket on-hold until a date,

Lee Bowers
Tera Contributor

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.

1 ACCEPTED SOLUTION

Prasad Dhumal
Mega Sage
Mega Sage

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

View solution in original post

1 REPLY 1

Prasad Dhumal
Mega Sage
Mega Sage

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