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
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

}

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@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Schincke,
Keith D. (JSC-IT)[MEI]
Sent: Wednesday, June 13, 2007 4:53 PM
To: RT-Users@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@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

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.

KenOn 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@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Schincke,
Keith D. (JSC-IT)[MEI]
Sent: Wednesday, June 13, 2007 4:53 PM
To: RT-Users@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

}


The rt-users Archives

Community help: http://wiki.bestpractical.com Commercial support:
sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

The Wiki description was great. It allowed the creation of the approval
process where one person or any person in a group could approve a
ticket.

What I need is a way to call the template for each member of the group
with the result of creating a ticket for each member that must be
approved before the parent ticket can start.

Keith SchinckeFrom: Kenneth Marshall [mailto:ktm@rice.edu]
Sent: Thursday, June 14, 2007 4:05 PM
To: Schincke, Keith D. (JSC-IT)[MEI]
Cc: RT-Users@lists.bestpractical.com
Subject: Re: [rt-users] Create multiple tickets from a template

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

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@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of
Schincke, Keith D. (JSC-IT)[MEI]
Sent: Wednesday, June 13, 2007 4:53 PM
To: RT-Users@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

}


The rt-users Archives

Community help: http://wiki.bestpractical.com Commercial support:
sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com


The rt-users Archives

Community help: http://wiki.bestpractical.com Commercial support:
sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

The Wiki description was great. It allowed the creation of the
approval
process where one person or any person in a group could approve a
ticket.

What I need is a way to call the template for each member of the group
with the result of creating a ticket for each member that must be
approved before the parent ticket can start.

Keith Schincke

I had a similar case. I don’t think what I am about to show will
completely solve your issue, but might help to point you in the right
direction.

Our scenario was 1st approval was by any member of the HR dept. the
second approval had to come from the requesters supervisor. The
requester had to input his/her supervisor in a customfield (pick one).
I used the supervisors RT username in the custom field options.

Ticket two was not visible to the supervisor until Ticket One was
approved, even though both Ticket One and Ticket Two were both created
when the user submitted the request.

I image you can use the AdminCC part on the first ticket for your
groups (I got that from the wiki) Then create as many tickets as you
need to just by adding "===Create-Ticket: " sections to your template.
just remember to add the “Depends-On: ” part to each
of your sections.

The template was:

===Create-Ticket: hr-approval
Depended-On-By: TOP
Queue: TimeOff-Approval
Type: approval
Owner:
AdminCC: {
my $group_name = ‘human_resources’;
my $groups = RT::Groups->new( $RT::SystemUser );

$groups->LimitToUserDefinedGroups();
$groups->Limit(
‘FIELD’ => ‘Name’,
‘OPERATOR’ => ‘=’,
‘VALUE’ => $group_name );
$groups->First->Id;
}
Content:
ENDOFCONTENT

===Create-Ticket: super-approval
Depended-On-By: TOP
Depends-On: hr-approval
Queue: TimeOff-Approval
Type: approval
{ my $owner = $Tickets{‘TOP’}->FirstCustomFieldValue(‘Supervisor’);
my $OUTPUT = “Owner: $owner”;
$OUTPUT;
}
Content:

ENDOFCONTENT

http://gentgeen.homelinux.org

Associate yourself with men of good quality if you esteem
your own reputation; for 'tis better to be alone then in bad
company. - George Washington, Rules of Civility