Notification event for TicketAccountTime
Moderator: crythias
Notification event for TicketAccountTime
Hi,
OTRS 3.3.6 (and earlier) allows notifications to be sent for the TicketAccountTime event. I assumed -- and tests still seem to suggest -- that this event is fired if an agent enters a value into the Time Accounting field of a ticket.
My first question is whether this is indeed the case? Is this what the OTRS devs had in mind with this event? I am actually looking for this, I need it this way. Just want to be absolutely sure.
My problem however is that I could not find any notification tag i.e. OTRS_TICKET_xxx that would actually print the value entered by the agent into the notification email.
Does anybody ever used this TicketAccountTime event for firing a notification and if yes, did you find the proper OTRS tag for the time unit value entered into the ticket?
This would be very handy to send to the customers automatically so they would be aware of how much time has been spent on their tickets.
Thanks a lot!
Kind regards,
Peter
OTRS 3.3.6 (and earlier) allows notifications to be sent for the TicketAccountTime event. I assumed -- and tests still seem to suggest -- that this event is fired if an agent enters a value into the Time Accounting field of a ticket.
My first question is whether this is indeed the case? Is this what the OTRS devs had in mind with this event? I am actually looking for this, I need it this way. Just want to be absolutely sure.
My problem however is that I could not find any notification tag i.e. OTRS_TICKET_xxx that would actually print the value entered by the agent into the notification email.
Does anybody ever used this TicketAccountTime event for firing a notification and if yes, did you find the proper OTRS tag for the time unit value entered into the ticket?
This would be very handy to send to the customers automatically so they would be aware of how much time has been spent on their tickets.
Thanks a lot!
Kind regards,
Peter
otrs 4.0.3, mysql 5.5.15, Fedora r15
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Notification event for TicketAccountTime
It doesn't happen. The event seeks TicketGet but TicketGet doesn't also return time.
It's an easy-ish fix by adding a call to TicketAccountedTimeGet (theoretically, optionally/with a flag) within Ticket.pm
It's an easy-ish fix by adding a call to TicketAccountedTimeGet (theoretically, optionally/with a flag) within Ticket.pm
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Re: Notification event for TicketAccountTime
Thanks crythias, I will try this then. Would you think it would make sense to suggest adding this fix to the code on IdeaScale? Or is this not that frequent of a request that it would make it through?
Cheers,
Peter
Cheers,
Peter
otrs 4.0.3, mysql 5.5.15, Fedora r15
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Notification event for TicketAccountTime
It's not unreasonable to suggest it on IdeaScale.pekkaar wrote:Would you think it would make sense to suggest adding this fix to the code on IdeaScale? Or is this not that frequent of a request that it would make it through?
I have differing opinions on whether the customer should know the hours spent before I bill him, because I might be adjusting the time internally up or down relative to other factors (including data entry problems) than actual time spent. It's hard to take that back once the customer has been notified.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Re: Notification event for TicketAccountTime
Ahh, but TicketAccountedTimeGet returns the total time accumulated on the ticket so far. I am more interested in the time value the TicketAccountTime event was generated for in the first place (so, quite possibly the last entry for the given ticket_id and user_id in time_accounting table).
I guess I would need to add a new method to Kernel\System\Ticket.pm that would return this then, as well as adding a call to this new sub from Kernel\System\Ticket~Event\NotificationEvent.pm's SendNotification() sub...
So I think I will do this and thus will be able to provide the last time value the agent involved with this TicketAccountTime event as well as the total summary of all acocunted time units for the given ticket. I guess it would be nice if OTRS would actually do this officially at one point.
Cheers,
Peter
I guess I would need to add a new method to Kernel\System\Ticket.pm that would return this then, as well as adding a call to this new sub from Kernel\System\Ticket~Event\NotificationEvent.pm's SendNotification() sub...

So I think I will do this and thus will be able to provide the last time value the agent involved with this TicketAccountTime event as well as the total summary of all acocunted time units for the given ticket. I guess it would be nice if OTRS would actually do this officially at one point.

Cheers,
Peter
otrs 4.0.3, mysql 5.5.15, Fedora r15
Re: Notification event for TicketAccountTime
I would agree with you on a more generic scale -- and I would understand if this idea would be voted down on the grounds you mention -- however in our case it is actually the way to go.crythias wrote:I have differing opinions on whether the customer should know the hours spent before I bill him, because I might be adjusting the time internally up or down relative to other factors (including data entry problems) than actual time spent. It's hard to take that back once the customer has been notified.
The notification could actually be sent to an agent or agents (supervisors, managers, etc), not necessarily to the customer right away. Though in my case this is actually the situation.
Cheers,
Peter
otrs 4.0.3, mysql 5.5.15, Fedora r15
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Notification event for TicketAccountTime
For my implementation, it would be good to see in the TicketZoom sidebar the TimeAccounting (sum) per agent (and total) for the ticket.pekkaar wrote: I guess it would be nice if OTRS would actually do this officially at one point.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Re: Notification event for TicketAccountTime
OK, so I added the following sub to Custom\Kernel\System\Ticket\Ticket.pm
And am now trying to call this from Custom\Kernel\System\Ticket\Event\NotificationEvent.pm, from _SendNotification():
But it crashes on me at "$Self->{TicketObject}->TicketLastUserAccountedTimeGet(%Ticket)". It is as if my new sub in Ticket.pm could not make it into this TicketObject object in NotificationEvent.
Can there be a cache of some sort apart from the mod_perl? I of course restarted apache numerous times either with "systemctl restart httpd.service" or stop and then start.
Any ideas?
Much appreciated!
Kind regards,
Peter
Code: Select all
sub TicketLastUserAccountedTimeGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Needed (qw(TicketID UserID)) {
if ( !$Param{$Needed} ) {
$Self->{LogObject}->Log( Priority => 'error', Message => "Need $Needed!" );
return;
}
}
# db query
return if !$Self->{DBObject}->Prepare(
SQL => 'SELECT time_unit FROM time_accounting WHERE ticket_id = ? AND create_by = ? ORDER BY change_time DESC LIMIT 1',
Bind => [ \$Param{TicketID}, \$Param{UserID} ],
);
my $AccountedTime = 0;
while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
$Row[0] =~ s/,/./g;
$AccountedTime = $AccountedTime + $Row[0];
}
return $AccountedTime;
}
Code: Select all
# Retrieve the total time accounted on the ticket as well as the last time unit entered by this user
my $TotalAccountedTime = $Self->{TicketObject}->TicketAccountedTimeGet(%Ticket);
my $LastUserAccountedTime = $Self->{TicketObject}->TicketLastUserAccountedTimeGet(%Ticket);
$Notification{Body} =~ s/<OTRS_TICKET_TOTALACCOUNTEDTIME>/TotalAccountedTime/gi;
$Notification{Subject} =~ s/<OTRS_TICKET_TOTALACCOUNTEDTIME>/TotalAccountedTime/gi;
$Notification{Body} =~ s/<OTRS_TICKET_LASTUSERACCOUNTEDTIME>/LastUserAccountedTime/gi;
$Notification{Subject} =~ s/<OTRS_TICKET_LASTUSERACCOUNTEDTIME>/LastUserAccountedTime/gi;
Can there be a cache of some sort apart from the mod_perl? I of course restarted apache numerous times either with "systemctl restart httpd.service" or stop and then start.
Any ideas?
Much appreciated!
Kind regards,
Peter
otrs 4.0.3, mysql 5.5.15, Fedora r15
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Notification event for TicketAccountTime
The exact error message would be helpful.
Note that you're returning exactly one row of data. In that case, you don't really need a while FetchrowArray();
You could simply:
my @Row = $Self->{DBObject}->FetchrowArray();
You also don't need to sum either.
Note that you're returning exactly one row of data. In that case, you don't really need a while FetchrowArray();
You could simply:
my @Row = $Self->{DBObject}->FetchrowArray();
You also don't need to sum either.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Re: Notification event for TicketAccountTime
Hi Crythias,
apologies for not mentioning it, there are no error messages whatsoever in the logs, or on the web. OTRS simply does not perform any notification when the problem occurs.
I am assuming it crashes because whenever I uncomment the line I highlighted previously in NotificationEvent.pm, it simply does not move accross that point and no notification is performed at all. As soon as I re-comment "$Self->{TicketObject}->TicketLastUserAccountedTimeGet(%Ticket)" it immediately starts working OK. I know because I put extra logging in NotificationEvent.pm surrounding this line.
So, I am assuming the $Self->{TicketObject} simply knows nothing of my new sub TicketLastUserAccountedTimeGet()... but how can that be? Unless I am adding it to the wrong Ticket.pm... baffled.
Thanks for spotting the resultset unnecesarry sum-up. I simply copied the code from another sub, I know it makes no sense since the SQL query is limited to 1, but it should not produce any error either. I intended to remove this as soon as it starts to work. But, I also tested the sub with uncommenting the whole db query part and simply returned 1 at the end. Failed that way too, as expected.
I actually can ask this in a much simpler fashion: ARE there any "sub caching"? Or should one declare any new subs in some "header" file, an XML, or anything, apart from the actual core module where the definition is added, like this Ticket.pm?
Or should this just work?
Cheers,
Peter
apologies for not mentioning it, there are no error messages whatsoever in the logs, or on the web. OTRS simply does not perform any notification when the problem occurs.
I am assuming it crashes because whenever I uncomment the line I highlighted previously in NotificationEvent.pm, it simply does not move accross that point and no notification is performed at all. As soon as I re-comment "$Self->{TicketObject}->TicketLastUserAccountedTimeGet(%Ticket)" it immediately starts working OK. I know because I put extra logging in NotificationEvent.pm surrounding this line.
So, I am assuming the $Self->{TicketObject} simply knows nothing of my new sub TicketLastUserAccountedTimeGet()... but how can that be? Unless I am adding it to the wrong Ticket.pm... baffled.
Thanks for spotting the resultset unnecesarry sum-up. I simply copied the code from another sub, I know it makes no sense since the SQL query is limited to 1, but it should not produce any error either. I intended to remove this as soon as it starts to work. But, I also tested the sub with uncommenting the whole db query part and simply returned 1 at the end. Failed that way too, as expected.
I actually can ask this in a much simpler fashion: ARE there any "sub caching"? Or should one declare any new subs in some "header" file, an XML, or anything, apart from the actual core module where the definition is added, like this Ticket.pm?
Or should this just work?
Cheers,
Peter
otrs 4.0.3, mysql 5.5.15, Fedora r15
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Notification event for TicketAccountTime
you might try deletcache.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Re: Notification event for TicketAccountTime
My bad (as usual) -- I copied that flippin Ticket.pm into the wrong subfolder within Custom\Kernel\System... darn! As soon as I moved it to the proper place it started to work. Apologies for the noise and thanks for the effort crythias, as usual!
Regards,
Peter
Regards,
Peter
otrs 4.0.3, mysql 5.5.15, Fedora r15