Stop ticket re-opening after WP Closed

Hi,

I was wondering if there is a way to enable ticket re-opening for the tickets that have been opened that day (which I managed to do with Reopen closed ticket), but to make it impossible once the work period has been closed ?

In France, a tax law makes it obligatory to stop tickets being reopened after the day has ended.

Thanks for your help !

You could add a constraint that Ticket Date must equal Date. However if you are open past midnight, this may not a solution.

Iā€™ve edited this post to work with current work periods

Iā€™ll be reusing actions/rules from the following tutorial:

With the above tutorial, I did not see anywhere where the ticket number or ID is passed to any actions/rules.

The way around it is to manually enter the ticket number (visible on the top left of the ticket). There may be another way, but I know this one works.

Script:

Script Name: Reopen Check
Handler: reopen

function check(ticketid)
{
  qtd = "SELECT FORMAT(Date, 'yyyy-MM-ddTHH:mm:ss') FROM Tickets WHERE Id = '"+ticketid+"'";
  var rtd = sql.Exec(qtd)[0];
  
  qwp = "SELECT FORMAT(StartDate, 'yyyy-MM-ddTHH:mm:ss') FROM WorkPeriods WHERE Id = (SELECT MAX(Id) FROM WorkPeriods WHERE StartDate = EndDate)";
  var rwp = sql.Exec(qwp)[0];

  if (rtd >= rwp)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}

Actions:

26-04-2020_19;08_1587949710_Samba.Presentation
Action Name: Reopen - Load Ticket
Action Type: Load Ticket
Ticket Number: [:Ticket Number]

26-04-2020_19;08_1587949727_Samba.Presentation
(if you donā€™t already have one)
Action Name: Execute Automation Command
Action Type: Execute Automation Command
Automation Command Name: [:Command Name]
Command Value: [:Command Value]

26-04-2020_19;32_1587951167_Samba.Presentation
Action Name: MSG TEST
Action Type: Show Message
Message: [:Message]

Rules:
26-04-2020_19;34_1587951291_Samba.Presentation
26-04-2020_21;56_1587959798_Samba.Presentation
Rule Name: Reopen
Event Name: Automation Command Executed
Execute Rule if: [Matches]
Custom Constraint:
**Automation Command [Equals] Reopen
** or set this to the button you currently have visible on the ticket screen

Actions to Add:

Action: Reopen - Load Ticket
Constraint:
Ticket Number: [?Ticket Number;\d*;;OCN]

Action: Execute Automation Command
Constraint: {CALL:reopen.check(ā€˜{TICKET ID}ā€™)} == 1
Command Name: Reopen - Reopen Ticket
Command Value: {TICKET ID}

Action: MSG TEST
Constraint: {CALL:reopen.check(ā€˜{TICKET ID}ā€™)} == 0
Message: Ticket out-of-range\rUnable to reopen

26-04-2020_19;09_1587949770_Samba.Presentation
Change the Custom Constraint for RU Reopen Settled Ticket:

Custom Constraint:
Automation Command Name [Equals] Reopen - Reopen Ticket

Reopening ticket from today:
26-04-2020_19;30_1587951018_%pn

Reopening ticket from not today:
26-04-2020_19;43_1587951818_%pn

EDIT: Updated script

I was just thinking, you could combine this with ticket logging for better tracking.

Wow, thanks !

Iā€™ll give it a try :wink:

Change the script to the following (I didnā€™t test with a closed work period - this will work if WP is closed):

function check(ticketid)
{
  qtd = "SELECT FORMAT(Date, 'yyyy-MM-ddTHH:mm:ss') FROM Tickets WHERE Id = '"+ticketid+"'";
  var rtd = sql.Exec(qtd)[0];
  
  qwp = "SELECT FORMAT(StartDate, 'yyyy-MM-ddTHH:mm:ss') FROM WorkPeriods WHERE Id = (SELECT MAX(Id) FROM WorkPeriods WHERE StartDate = EndDate)";
  var rwp = sql.Exec(qwp)[0];

  if (rtd >= rwp)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}

I was thinking something a little less exciting. Just add a Custom Constraint:
T1kZVARpb0

{TICKET DATE} Equals {DATE}

I like the idea of another rule to show a message about not being able to reopen ticket.

Of course the non-exciting way would be duplicate the rule, change `{TICKET DATE} Equals {DATE}ā€™ to ā€˜{TICKET DATE} Not Equals {DATE}ā€™, remove all actions and add the Show Message action.

That sounds viable provided single work period per day and not spanning days ie after midnight.

That was my original thought; you can see it going back to the original in the edits. But then I forgot about the WP requirement. Pesky detailsā€¦

1 Like

This quarantine business sucks! Iā€™ve got too much time on my hands.

Here is an option to use workperiods instead of Ticket Date and Date:

{REPORT TICKET DETAILS:W.Id:(Ticket.Id={TICKET ID})} Equals {WORKPERIOD ID}

This will use the workperiod id of the ticket against the current workperiod. This would work if open past midnight and not using virtual workperiods (I think). However, if a workperiod was forgotten to end the previous day, it would be possible to re-open the ticket the following day.

1 Like

Yes however the ticket would still be in the current work period so wouldnā€™t cause already reported period figure changes. Yes you have have already printed (a x type read) however the running total would make it still a ā€˜liveā€™ ticket.

Add '{SETTING:ISCURRENTWORKPERIODOPEN}' == 'TRUE' to the constraint to Execute Automation Command and it works. A simpler solution - love it!

Without that constraint I was able to reopen and resettle a ticket with no open work period. Iā€™m actually quite curious what thatā€™ll do to reports.

2 Likes