
Dear Alexander Alexander Scholler schreef:
It can be configured => PostmasterFollowUpState I set it to "new - extended", a new state of type "new" I added to OTRS with "System > States"-setup.
I have configured an additional state "new followup" and when a followup is received for an existing ticket it gets this state.
* create a generic agent job that searches for all locked tickets with that specific state Search for tickets with new state that are locked. Am I right?
Right.
I have created a GenericAgent job that does just that. When you modify it it will give you a list of the tickets affected. That works fine.
Very-very-small instructions for writing such a module: * make a copy of ~/Kernel/System/GenericAgent/AutoPriorityIncrease.pm * edit this copy to not increase the priority but to do the unlocks if necessary
I have modified the module as you suggested. I have attached the module to this message. It unlocks tickets that are locked and in state "new followup" for a configurable duration. It takes working time into account. This all works fine. I have only one problem left. I have also copied a piece of code from the NotifyAgentGroupofCustomQueue module to send a "followup" notification to all agents that are subscribed to the queue the unlocked ticket is in. When I run the generic agent I get the following error message in the web-browser window: Software error: Can't call method "GetUserData" on an undefined value at ../..//Kernel/System/GenericAgent/UnlockAfterFollowup.pm line 110. I am not sure what is going wrong here. Can you give me a tip? Many thanks for your help so far. Regards, Jurgen # -- # Kernel/System/GenericAgent/UnlockAfterFollowup.pm # -- package Kernel::System::GenericAgent::UnlockAfterFollowup; use strict; use vars qw(@ISA $VERSION); $VERSION = '$Revision: 1.0 $'; $VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/; # -- sub new { my $Type = shift; my %Param = @_; # allocate new hash for object my $Self = {}; bless ($Self, $Type); # check needed objects foreach (qw(DBObject ConfigObject LogObject TicketObject TimeObject)) { $Self->{$_} = $Param{$_} || die "Got no $_!"; } # 0=off; 1=on; $Self->{Debug} = $Param{Debug} || 0; return $Self; } # -- sub Run { my $Self = shift; my %Param = @_; my $Update = 0; my $LatestUpdate = 0; my $CountedTime; # check needed param if (!$Param{New}->{"TimeInterval"}) { $Self->{LogObject}->Log( Priority => 'error', Message => "Need TimeInterval param for GenericAgent module!", ); return; } else { $Param{New}->{"TimeInterval"} = $Param{New}->{"TimeInterval"} * 60; } # get ticket data my %Ticket = $Self->{TicketObject}->TicketGet(%Param); # find latest change date in ticket $LatestUpdate = $Ticket{Changed}; # Convert latest change date into System time format $LatestUpdate = $Self->{TimeObject}->TimeStamp2SystemTime( String => $LatestUpdate, ); # Calculate the duration since last change in working time only $CountedTime = $Self->{TimeObject}->WorkingTime( StartTime => $LatestUpdate, StopTime => $Self->{TimeObject}->SystemTime(), ); $Self->{LogObject}->Log( Priority => 'debug', Message => "CountedTime = $CountedTime", ); # If duration exceeds maximum lock duration then ticket must be unlocked if ($CountedTime > $Param{New}->{"TimeInterval"}) { $Update = 1; } # check if ticket needs to be unlocked if (!$Update) { # do nothing if ($Self->{Debug}) { $Self->{LogObject}->Log( Priority => 'debug', Message => "Nothing to do on (Ticket=$Ticket{TicketNumber}/TicketID=$Ticket{TicketID})!", ); } return 1; } else { # unlock ticket $Self->{TicketObject}->LockSet( Lock => 'Unlock', TicketID => "$Ticket{TicketID}", UserID => "$Ticket{UserID}", ); # log message $Self->{LogObject}->Log( Priority => 'notice', Message => "Ticket=$Ticket{TicketNumber}/TicketID=$Ticket{TicketID} unlocked due to agent inactivity!", ); # get agentss who are sucscribed the ticket queue to the custom queues my @UserIDs = $Self->{TicketObject}->GetSubscribedUserIDsByQueueID( QueueID => $Ticket{QueueID}, ); # send each agent the unlock notification foreach (@UserIDs) { $Self->{LogObject}->Log( Priority => 'notice', Message => "UserID = $_", ); my %User = $Self->{UserObject}->GetUserData(UserID => $_); # send agent notification $Self->{TicketObject}->SendAgentNotification( Type => 'FollowUp', UserData => \%User, CustomerMessageParams => \%Param, TicketID => $Ticket{TicketID}, UserID => 1, ); }; return 1; } } # -- 1;