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.
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;
}
}
Action Name: MSG TEST
Action Type: Show Message
Message: [:Message]
Rules:
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
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:
{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.
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.
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.