[rt-users] Create multiple tickets from a template

Kenneth Marshall ktm at rice.edu
Thu Jun 14 17:04:36 EDT 2007


Keith,

How is it going down there? I think the wiki has a pretty good description
of this process. This is managed by using a template to create the needed
tickets. The RT Essentials book also describes the process on p.94.

Ken

On Thu, Jun 14, 2007 at 03:53:02PM -0500, Schincke, Keith D. (JSC-IT)[MEI] wrote:
> Hey Guys,
> 
> Below is a V1.0 script to create an approval ticket for each member of
> the approval group when ever a ticket requiring approval is created. It
> works as I need except the outgoing messages for the new tickets are not
> being sent. 
> 
> Let me know if you have any suggestions or questions
> 
> Keith Schincke
> 
> Go to Configuration->Queues->Your Queue->Scrips->New scrip
> 
> Description: Your Scrip Description
> Condition: On Create
> Action: User Defined
> Template: Global Template: Blank
> Stage: TransactionCreate
> 
> Custom action preparation code:
> my $queue_name = 'Approvals' ;
> my $group_name='outage_approval' ;
> my $group = RT::Group->new( $RT::SystemUser );
> 
> $group->LoadUserDefinedGroup( $group_name );
> $RT::Logger->debug(">>Error : couldn't load group") and die "Cannot load
> group" unless $group->id; 
> 
> my $ticket = $self->TicketObj ;
> my $req_addr = $self->TicketObj->RequestorAddresses ;
> my $tick_id = $self->TicketObj->id ;
> my $tick_sub = $ticket->Subject ;
> 
> my $child_ticket = RT::Ticket->new ( $RT::SystemUser ) ;
> 
> my $users = $group->UserMembersObj;
> while ( my $user = $users->Next ) {
> 	my $name = $user->Name ;
> 
> 	my ($child_id, $child_transobj, $errormsg ) =
> $child_ticket->Create(
> 			Queue => $queue_name ,
> 			Subject => "Approval review for " .
> $ticket->Subject . " (" . $ticket->id . ")" ,
> 			RefersTo => $ticket->id ,
> 			DependedOnBy => $ticket->id ,
> 			Type => "approval" ,
> 			Reqestor => $req_addr,
> 			Owner => $user ,
> 		) ;
> 	unless ( $child_id ) 
> 	{
> 		$RT::Logger->debug(">>Error : ". $errormsg);
> 		return undef ;
> 	}
> 
> }
>  
> 
> -----Original Message-----
> From: rt-users-bounces at lists.bestpractical.com
> [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Schincke,
> Keith D. (JSC-IT)[MEI]
> Sent: Wednesday, June 13, 2007 4:53 PM
> To: RT-Users at lists.bestpractical.com
> Subject: [rt-users] Create multiple tickets from a template
> 
> Hey Guys
> 
> I am using RT 3.6.1 on a Debian etch server with a mysql backend. 
> 
> I am trying to create multiple tickets in the approval queue each with
> an owned by a member from the approval group with the idea that the
> parent ticket is approved when each member of the group has approved of
> their approval ticket. 
> 
> It is possible to write a template that will on the "On Create"
> condition take the "Create Tickets" action and open multiple tickets?
> 
> Below is a template I worked up.  I was trying to call the create ticket
> template for each user in the group.
> 
> Would this be better solved with a "User Defined" action on the script.
> 
> Thanks for any pointers and information.
> 
> Keith
> 
> my $group_name='approval_group' ;
> my $group = RT::Group->new( $RT::SystemUser );
> $group->LoadUserDefinedGroup( $group_name ); die "couldn't load group"
> unless $group->id; 
> 
> my $users = $group->UserMembersObj;
> while ( my $user = $users->Next ) {
>     #print $user->Name, "\n";
> 
> ===Create-Ticket: approvalreview
> Subject: Approval review for "{$Tickets{'TOP'}->Subject}"
> Depended-On-By: {$Tickets{'TOP'}->Id()}
> Refers-To: {$Tickets{'TOP'}->Id()}
> Owner: { $user }
> Queue: Approvals
> Type: approval
> Content: 
> { $Transaction->CreatorObj->Name } ({ $Ticket->RequestorAddresses }) has
> created a ticket requiring your approval You should review and approve
> it, so they can finish their work.
> ENDOFCONTENT
> 
> }
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Community help: http://wiki.bestpractical.com Commercial support:
> sales at bestpractical.com
> 
> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
> Buy a copy at http://rtbook.bestpractical.com
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
> 
> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
> 



More information about the rt-users mailing list