[rt-users] Action Upon Approval
Todd Chapman
rt at chaka.net
Mon Dec 13 13:11:49 EST 2004
I create a custom field called 'Resolve Action' that creates a new
ticket when the current ticket is resolved. This allows for
very simple (2 steps) workflow. This scrip is kind of complicated
because of other things we do, but I can share some snippets:
Custom condition:
my $trans = $self->TransactionObj->Type;
if ($trans eq 'Status' && $self->TransactionObj->NewValue =~ /(resolved|rejected|deleted)/i) {
return 1;
}
Custom action preparation code:
1;
Custom action cleanup code:
if ($status =~ /Resolved/i) {
my $cfValues = $self->TicketObj->CustomFieldValues('Resolve Action');
if ($cfValues->Count) {
$RT::Logger->debug("Processing resolve actions: " . $cfValues->Count);
# run resolve_action
# for each action, create a ticket, set its parent to my parent
# (assuming one parent)
my @new_tickets;
while (my $value = $cfValues->Next) {
#$RT::Logger->debug("Resolve value: '$value'");
my $ticket = new RT::Ticket($RT::SystemUser);
#need to set Queue Requestor Cc AdminCc Type? Subject
my ($reqtype,$AdminCc,$Cc) = split(/:/, $value->Content);
my $type; #20
if ($reqtype =~ /approval/i) { $type = 'approval'; }
else { $type = 'ticket'; }
my $content;
if ($self->TicketObj->Transactions->First) {
$content = MIME::Entity->build(Charset => 'utf8', Data => $self->TicketObj->Transactions->First->Content);
}
my %ticket_args = (
Subject => $self->TicketObj->Subject,
Queue => $self->TicketObj->QueueObj->Name,
Requestor => $self->TicketObj->RequestorAddresses,
Cc => $Cc,
AdminCc => $AdminCc,
Type => $type,
MIMEObj => $content || undef,
);
if ($self->TicketObj->MemberOf->First) {
$ticket_args{MemberOf} =
$self->TicketObj->MemberOf->First->TargetObj->Id;
}
else {
$ticket_args{MemberOf} = $self->TicketObj->Id;
}
#need to set custom field
my $customfield = new RT::CustomField($RT::SystemUser);
$customfield->LoadByNameAndQueue(Queue => $self->TicketObj->QueueObj->Name, Name => "Request Type");
my $cfid = $customfield->Id;
$ticket_args{"CustomField-$cfid"} = $value->Content;
$RT::Logger->debug("Setting cf $cfid to: " . $value->Content);
my ($id, undef, $msg) = $ticket->Create(%ticket_args);
$RT::Logger->debug("Created ticket from resolve action: " . $id);
$RT::Logger->debug("Ticket creation error: $msg") unless $id;
next unless $id;
push @new_tickets, $id;
#then add comment for parent first and last? #50
}
unless (@new_tickets) {
$RT::Logger->debug("No resolve actions successful for ticket: " . $self->TicketObj->Id);
return 1;
}
On Mon, Dec 13, 2004 at 11:55:41AM -0500, Ben Blakely wrote:
> Hello All,
>
> I have configured the Approvals within RT. I was wondering if anyone
> has an idea on howto get an action to be performed after approval.
>
> For example, id like to create a child ticket within another queue
> once the initial approval has been approved.
>
> Regards,
>
> Ben Blakely
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Be sure to check out the RT wiki at http://wiki.bestpractical.com
More information about the rt-users
mailing list