[rt-users] Setting Due date and Subject off of another ticket
Jared Hanks
jmhanks1373 at hotmail.com
Tue Nov 7 17:13:20 EST 2006
I figured out how to set the Subject. I changed:
my $TicketId = $TicketObjItem->Create(Queue => $count, Type => "Ticket", RefersTo => $self->TicketObj->Id);$TicketObjItem->SetSubject("Delete $self->TicketObj->Subject");
to:
my $subject = $self->TicketObj->Subject;
my $TicketId = $TicketObjItem->Create(Queue => $count, Type => "Ticket", Subject => "Delete $subject", RefersTo => $self->TicketObj->Id);
I'm still unable to set the Due date. I did remember that I have a scrip that also runs when a new ticket gets created. It is:
Custom action preparation code:
return 1;
--------------------------------------
Custom action clean up code:
1;
my $AttachObj = $self->TransactionObj->Attachments->First;# go out if content is not text!unless( $AttachObj->ContentType =~ /^text/ ){return 1;}
my $content = $AttachObj->Content;if($self->TicketObj->Subject =~/TemporaryAccess/i){my $tickID = $self->TicketObj->Id+1;$tickID->TicketObj->SetDue(Format=>"ISO", Value=>$1);}if( $content =~ m/^\QSet-Starts:\E\s*(\S+)\s*$/m ){$self->TicketObj->SetStarts( $1 );}if( $content =~ m/^\QSet-Due:\E\s*(\S+)\s*$/m ){$self->TicketObj->SetDue(Format=>"ISO", Value=>$1);}if( $content =~ m/^\QSet-Owner:\E\s*(\S+)\s*$/m ){$self->TicketObj->SetOwner( $1 );}if( $content =~ m/^\QSet-Status:\E\s*(\S+)\s*$/m ){$self->TicketObj->SetStatus( $1 );}if( $content =~ m/^\QSet-Time-Worked:\E\s*(\S+)\s*$/m ){$self->TicketObj->SetTimeWorked( $1);}
# strip special commands from email content#$content =~ s/^\QSet-Starts:\E\s*(\S+)\s*$//gm;#$content =~ s/^\QSet-Due:\E\s*(\S+)\s*$//gm;$content =~ s/^\QSet-Status:\E\s*(\S+)\s*$//gm;$content =~ s/^\QSet-Owner:\E\s*(\S+)\s*$//gm;$content =~ s/^\QSet-Time-Worked:\E\s*(\S+)\s*$//gm;
# silently overwrite attachment content$AttachObj->__Set( Field => 'Content', Value => $content );
1;
-----------------------------------------------------------------------------------------
Any help is greatly appreciated.
Thanks,
Jared
From: jmhanks1373 at hotmail.comTo: rt-users at lists.bestpractical.comDate: Mon, 6 Nov 2006 18:55:36 -0800Subject: [rt-users] Setting Due date and Subject off of another ticket
Hello, I am trying to set the date, and subject, of a ticket off of another ticket. When a ticket is created with the subject like "TemporaryAccess" another ticket is created and linked to the first ticket. I would like to set the Due date in Ticket2, based upon the due date of Ticket1. I have the following in my scrip.... Custom action preparation code: return 1;---------------------------------------------------------------------------------------------------------------------------------Custom action cleanup code: my $vari = $self->TicketObj->RequestorAddresses;my $UserObj = RT::User->new(RT::CurrentUser->new($RT::SystemUser));my ($id, $worked) = $UserObj->LoadOrCreateByEmail($vari);my $mygroup = $UserObj->OwnGroups;my $nextgroup = $mygroup->Next();my $count = $nextgroup->Name;my ($status, $msg) = $self->TicketObj->SetQueue($count);if($self->TicketObj->Subject =~/TemporaryAccess/i){my $TicketObjItem = RT::Ticket->new(RT::CurrentUser->new($RT::SystemUser));my $TicketId = $TicketObjItem->Create(Queue => $count, Type => "Ticket", RefersTo => $self->TicketObj->Id);$TicketObjItem->SetSubject("Delete $self->TicketObj->Subject");$TicketObjItem->AddCustomFieldValue( Field => '40', Value => "Access", RecordTransaction => 1 );unless( $status ) {$RT::Logger->warning( "Couldn't set Access as value for CF TicketType". $msg );return undef;}$TicketObjItem->AddCustomFieldValue( Field => '41', Value => "Separation", RecordTransaction => 1 );unless( $status ){$RT::Logger->warning( "Couldn't set Separation as value for CF AccessManagementType". $msg );return undef;}$TicketObjItem->SetDue(Format => "Date", Value => $self->TicketObj->Due);} ------------------------------------------------------------------------------------------------------------- Ticket1 is sent in via email with Set-Due: so Ticket1's Due is pulled from the email. It looks like the Due date is trying to be set, but doesn't actually set it. Ticket1 says:
#
Mon Nov 06 18:24:55 2006
RT_System - Due changed from Not set to Not set
#
Mon Nov 06 18:24:55 2006
RT_System - Due changed from Thu Nov 09 16:00:00 2006 to Not set and Ticket2 says: # Mon Nov 06 18:24:54 2006 RT_System - Due changed from Not set to Not set So it looks like Due is getting set on Ticket2 before Due is set on Ticket1??? Anyone have any ideas? Should I be doing this differently? Also, the subject of Ticket2 ends up coming out like "Delete RT::Action::UserDefined=HASH(0xb57baa8)->TicketObj->Subject". Any ideas on this either? Any help is greatly appreciated. Thanks,Jared
Try the next generation of search with Windows LiveT Search today! Try it!
_________________________________________________________________
Get the new Windows Live Messenger!
http://get.live.com/messenger/overview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20061107/74543610/attachment.htm>
More information about the rt-users
mailing list