[rt-users] scrip question : reply to resolved ticket must open a new ticket
Sebastien Person
sebastien.person at easter-eggs.com
Fri Mar 26 05:25:49 EST 2004
hi,
I use RT 3.0.9 and I trying to make a scrip to automatically catch reply to
resolved ticket and create a new ticket with content from the reply catched.
I haven't already write all the parts of the scrips, but I would like to get the
list advices on the best way to achieve this.
The scrip condition I want to use will look like this one :
Custom condition scrip :
------------------------
my $ticket = $self->TicketObj;
my $transaction = $self->TransactionObj;
$RT::Logger->debug(">>> Entering CustomCondition test : STATUS=" .
$ticket->Status. ", TYPE=" . $transaction->Type ."<<<");
if ($transaction->IsInbound() && $transaction->Status eq 'resolved'){
# && $transaction->Type eq 'Correspond' ) {
# && $ticket->Status eq 'resolved'
$RT::Logger->debug(">> The requestor correspond on his ticket.");
$RT::Logger->debug(">> But, we need to disable global Scrip On Correspond
Open to add constraint on the status.");
return(1);
} else {
return(undef);
}
The people who reply to the ticket must be the requestor (e.g customer), and the
status must be resolved. As far as I know I must disable On Correspond Open
ticket scrip to get it working. Do you know know another better way to detect
reply on resolved ticket ?
For the action scrip, I haven't allready put all that must be done, but
I create a new one ticket related to the old, create a subject related
to the old one, and add the correct requestor(s) to the ticket. I also
have a custom field for the customer that I must copy.
Now I must found a way to attach the mail received (the one in reply to resolved
ticket) to the new ticket and ideally don't let RT to add it on the old
ticket. I believe that I must deal with the transaction object and their
attachements but I'm not sure and don't know what are the revelant info that
must be copied ? Is there any method that allow to duplicate or ideally move
a correspondence fron one queue to another (didn't managed to found it in the
docs) ?
Anyway, here's follow what I have allready write in my scrip action :
Custom Action scrip:
--------------------
my $ticket = $self->TicketObj;
$RT::Logger->debug(">>> Entering Custom Action <<<");
$RT::Logger->debug(">> Ticket : id=". $ticket->EffectiveId );
# new ticket (cross link is automatic)
my $child_ticket = RT::Ticket->new($RT::SystemUser);
my ($child_id, $child_TransObj, $errorMsg) = $child_ticket->Create(Queue =>
$ticket->Queue,
Subject => 'suite du ticket #'. $ticket->Id .
' : ' . $ticket->Subject,
RefersTo => $ticket->Id);
unless ($child_id) {
$RT::Logger->debug(">>Error : ". $errorMsg);
return undef
}
# add requestors address
my $requestor = $ticket->RequestorAddresses;
$RT::Logger->debug(">> requestors addresses found : " . $requestor);
my @mails = split /,\s*/, $requestor; # transform mail list comma separated into
array
foreach my $email ( @mails) {
my ($ret, $errorMsg ) = $child_ticket->AddWatcher(Type => 'Requestor',
Email => $email);
if (!$ret) {
$RT::Logger->debug(">>Error : ". $errorMsg);
}
}
# find client customFielObj
my $customField = new RT::CustomField($RT::SystemUser);
my ($customFieldId, $errorMsg) = $customField->LoadByNameAndQueue( Name =>
"client",
Queue => $ticket->Queue);
unless ($customFieldId) { # check the global CF if the local doesn't exist
($customFieldId,$errorMsg) = $customField->LoadByNameAndQueue ( Name =>
"client",
Queue => 0);
}
# add custom fields for the client
# $cf_client = $ticket->FirstCustomFieldValue('client');
# another way by id .... as the named way didn't work for me
my $cf_client = 'none'; # by default client is none
if ($customFieldId) {
$cf_client = $ticket->FirstCustomFieldValue($customFieldId);
$RT::Logger->debug(">> CustomField found : " . $cf_client);
($ret, $errorMsg) = $child_ticket->AddCustomFieldValue( Field =>
$customFieldId,
Value => $cf_client); # 1=ok
unless ($ret) {
$RT::Logger->debug(">>Error : ". $errorMsg);
}
}
# close the old ticket
$ticket->SetStatus('resolved');
return 1;
Don't hesitate to comment my scrips as I'm not very familiar with RT, it would
help me to better understand it.
I hope that my problem description is clear, if it is not ask me and I will give
you more details. Any help will be very appreciated ...
Thanks for your help.
seb
More information about the rt-users
mailing list