Is it possible to back-date a ticket when closing it? If so , how?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2017 10:56 AM
Facilities would like to change the close date and back date it when closing. Is it a functionality currently available, if so, how?
- Labels:
-
Facilities Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2017 11:06 AM
I believe this could be done by adding a business rule that updates the closed field to the date desired. The important part would be that this BR runs after the OOB BR that sets the closed field.
With that said, I would push back against this requirement. I can't think of a good reason why we'd want to do this. What's the use case that's driving this requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 09:41 AM
Hi Mitali,
I found this question on the community where they were looking for a solution to close the ticket after 3 business days. As we all know, for example the "autoclose" for incident doesn't count business days, it just goes for "days". Which pretty much leaves people setting a high value enough so it would take care most of the short holidays and the customers won't be angry. This solution can be used on all kind of tickets.
EDIT: I also put this as an "idea" on the community, so go in and vote for it and see if we can get it into a future release: Be able to use Business hours/days to autoclose ticket
I will use the following stuff to get it to work:
- Relative Durations. I use this to set the amount of business days I want it to wait until it closes. Using relative duration
- DurationCalculator. To calculate the duration with a schedule. Using DurationCalculator to calculate a due date
- Schedule Job. Then I'll put the code in a schedule job that runs how often you want it to run to check and close those tickets that are "due".
- Get the sys_id for the relative duration I want to use
- Query all the records I want to go through. Active is true and got a resolve date is the ones I want here.
- Loop through the records I get and check if its been more than 3 business days since it was set to resolve. If it is, close it.
- (function(){
- //Get the relative duration for 3 business days
- var relDur = 'f3ae5fc70f0132004cf365ba32050eb9';
- //get the incidents that we want to go through
- var encQue = 'active=true^resolved_atISNOTEMPTY';
- var gr = new GlideRecord('incident');
- gr.addEncodedQuery(encQue);
- gr.query();
- while(gr.next()){
- //Calculate and see if resolve date is more than 3 business days ago. And if, close the ticket.
- var dc = new DurationCalculator();
- //Load the schedule into our calculation through the function below
- addSchedule(dc);
- //Do the calculation and see if end date is before today
- dc.setStartDateTime(gr.resolved_at);
- if (!dc.calcRelativeDuration(relDur)) {
- gs.error("*** calcRelativeDuration failed for record {0}", gr.number);
- }
- if (dc.getEndDateTime() < gs.nowDateTime()){
- gr.setValue('state', 7);
- gr.update();
- }
- }
- function addSchedule(durationCalculator) {
- // Load the "8-5 weekdays" schedule into our duration calculator.
- var scheduleName = "8-5 weekdays";
- var grSched = new GlideRecord('cmn_schedule');
- grSched.addQuery('name', scheduleName);
- grSched.query();
- if (!grSched.next()) {
- gs.error("*** Could not find schedule {0}.", scheduleName);
- return;
- }
- return durationCalculator.setSchedule(grSched.getUniqueValue(), "GMT");
- }
- })();
Aditya Telidevara