Action Upon Approval

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

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

It’s not fair unless everyone at home get to play along.

So, one step at a time:

Are you having a problem getting a scrip to run when a ticket
is resolved? My approach below is to create the 2nd ticket
when the first ticket is resolved, not before.

-ToddOn Mon, Dec 13, 2004 at 03:06:56PM -0500, Ben Blakely wrote:

Hey Todd,

Thanks for the reply. Im new to the custom fields and fairly familiar
with the user defined script stuff. I did create a custom field, and
read the documentation relating to it, but still dont understand how
this custom field helps to create a child ticket on resolve. Do you
think you could explain a little more? Basically, what Im trying to
accomplish is having a ticket come into a certain queue, request
approval for it, and upon approval create a child ticket in another
queue.

Ive figured out the Approval stuff and howto get a child created in
another queue, but cant seem to get RT to perform an action once its
been approved. I have even created scrips within those queue’s that
perform an action on resolve ( RT seems to put tickets into a resolved
status once approved ), to no avail.

I did create a script with the user defined information above and set
the stage to disabled. I also create a custom field named Resolve
Action for that queue, but tailing RT’s logs indicate its not doing
anything on resolve. Any kind of help relating to my setup would be
muchly appreciated.

Regards,

Ben Blakely

On Mon, 13 Dec 2004 13:11:49 -0500, Todd Chapman rt@chaka.net wrote:

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

Hey Todd,

It seems to be a problem with getting an action to be performed after
the child ( approval ticket ) is resolved. Im taking your approach,
when the approval ticket is resolved id like to have another ticket
created in another queue.

BenOn Mon, 13 Dec 2004 14:33:22 -0500, Todd Chapman rt@chaka.net wrote:

It’s not fair unless everyone at home get to play along.

So, one step at a time:

Are you having a problem getting a scrip to run when a ticket
is resolved? My approach below is to create the 2nd ticket
when the first ticket is resolved, not before.

-Todd

On Mon, Dec 13, 2004 at 03:06:56PM -0500, Ben Blakely wrote:

Hey Todd,

Thanks for the reply. Im new to the custom fields and fairly familiar
with the user defined script stuff. I did create a custom field, and
read the documentation relating to it, but still dont understand how
this custom field helps to create a child ticket on resolve. Do you
think you could explain a little more? Basically, what Im trying to
accomplish is having a ticket come into a certain queue, request
approval for it, and upon approval create a child ticket in another
queue.

Ive figured out the Approval stuff and howto get a child created in
another queue, but cant seem to get RT to perform an action once its
been approved. I have even created scrips within those queue’s that
perform an action on resolve ( RT seems to put tickets into a resolved
status once approved ), to no avail.

I did create a script with the user defined information above and set
the stage to disabled. I also create a custom field named Resolve
Action for that queue, but tailing RT’s logs indicate its not doing
anything on resolve. Any kind of help relating to my setup would be
muchly appreciated.

Regards,

Ben Blakely

On Mon, 13 Dec 2004 13:11:49 -0500, Todd Chapman rt@chaka.net wrote:

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

Can you get a simple scrip to work? Such as:

Condition: User Defined
Action: User Defined
Template: Global tempalte: Blank
Stage: TransactionCreate
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:

$RT::Logger->debug(“Resolve action running…”);On Mon, Dec 13, 2004 at 03:38:49PM -0500, Ben Blakely wrote:

Hey Todd,

It seems to be a problem with getting an action to be performed after
the child ( approval ticket ) is resolved. Im taking your approach,
when the approval ticket is resolved id like to have another ticket
created in another queue.

Ben

Todd,

I set that scrip up but not to sure if its running or not. However, I
can use the default scripts to do stuff, such as notifing CC’s on
reply.On Mon, 13 Dec 2004 15:07:46 -0500, Todd Chapman rt@chaka.net wrote:

Can you get a simple scrip to work? Such as:

Condition: User Defined
Action: User Defined
Template: Global tempalte: Blank
Stage: TransactionCreate
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:

$RT::Logger->debug(“Resolve action running…”);

On Mon, Dec 13, 2004 at 03:38:49PM -0500, Ben Blakely wrote:

Hey Todd,

It seems to be a problem with getting an action to be performed after
the child ( approval ticket ) is resolved. Im taking your approach,
when the approval ticket is resolved id like to have another ticket
created in another queue.

Ben

If you can’t get that simple scrip to run you have a problem. Do
you know where your RT is logging to? Also, you must resolve
a ticket to get the scrip to run…On Mon, Dec 13, 2004 at 04:56:56PM -0500, Ben Blakely wrote:

Todd,

I set that scrip up but not to sure if its running or not. However, I
can use the default scripts to do stuff, such as notifing CC’s on
reply.

Hey Todd,

I got the test script to work. But I still cant get the orginal code
you pasted to run, there is no debug from the “custom action code
cleanup” portion of the script. The test script displays the “resolve
action running…” on resolve of ticket, but doesnt make it to the
first debug message in the code I mentioned above.

Any suggestions? Im wondering if you could confirm my settings for the
custom field named 'Resolved Action.

Name: Resolve Action
Desc: To perform action on resolve.
Type: ‘Select one value’

Thanks,

BenOn Mon, 13 Dec 2004 16:24:36 -0500, Todd Chapman rt@chaka.net wrote:

If you can’t get that simple scrip to run you have a problem. Do
you know where your RT is logging to? Also, you must resolve
a ticket to get the scrip to run…

On Mon, Dec 13, 2004 at 04:56:56PM -0500, Ben Blakely wrote:

Todd,

I set that scrip up but not to sure if its running or not. However, I
can use the default scripts to do stuff, such as notifing CC’s on
reply.

My ‘Resolve Action’ CF is actually a select multiple CF, but I
don’t think that would affect the code.

Did you try resolving a ticket that had the CF set to some value?

-ToddOn Mon, Dec 13, 2004 at 08:41:51PM -0500, Ben Blakely wrote:

Hey Todd,

I got the test script to work. But I still cant get the orginal code
you pasted to run, there is no debug from the “custom action code
cleanup” portion of the script. The test script displays the “resolve
action running…” on resolve of ticket, but doesnt make it to the
first debug message in the code I mentioned above.

Any suggestions? Im wondering if you could confirm my settings for the
custom field named 'Resolved Action.

Name: Resolve Action
Desc: To perform action on resolve.
Type: ‘Select one value’

Thanks,

Ben
On Mon, 13 Dec 2004 16:24:36 -0500, Todd Chapman rt@chaka.net wrote:

If you can’t get that simple scrip to run you have a problem. Do
you know where your RT is logging to? Also, you must resolve
a ticket to get the scrip to run…

On Mon, Dec 13, 2004 at 04:56:56PM -0500, Ben Blakely wrote:

Todd,

I set that scrip up but not to sure if its running or not. However, I
can use the default scripts to do stuff, such as notifing CC’s on
reply.

Todd,

Excuse the delay. There still seems to be an issue with that scrip,
even when I device a Resolve Action. Ive even tried using the script
with a ticket that is not a “type approval” and still no go. Any
suggestions?

BenOn Tue, 14 Dec 2004 09:04:26 -0500, Todd Chapman rt@chaka.net wrote:

My ‘Resolve Action’ CF is actually a select multiple CF, but I
don’t think that would affect the code.

Did you try resolving a ticket that had the CF set to some value?

-Todd

On Mon, Dec 13, 2004 at 08:41:51PM -0500, Ben Blakely wrote:

Hey Todd,

I got the test script to work. But I still cant get the orginal code
you pasted to run, there is no debug from the “custom action code
cleanup” portion of the script. The test script displays the “resolve
action running…” on resolve of ticket, but doesnt make it to the
first debug message in the code I mentioned above.

Any suggestions? Im wondering if you could confirm my settings for the
custom field named 'Resolved Action.

Name: Resolve Action
Desc: To perform action on resolve.
Type: ‘Select one value’

Thanks,

Ben
On Mon, 13 Dec 2004 16:24:36 -0500, Todd Chapman rt@chaka.net wrote:

If you can’t get that simple scrip to run you have a problem. Do
you know where your RT is logging to? Also, you must resolve
a ticket to get the scrip to run…

On Mon, Dec 13, 2004 at 04:56:56PM -0500, Ben Blakely wrote:

Todd,

I set that scrip up but not to sure if its running or not. However, I
can use the default scripts to do stuff, such as notifing CC’s on
reply.

Start adding/uncommenting debug statements and figure out where
things are going wrong. let me know what you find.

-ToddOn Thu, Dec 16, 2004 at 04:00:02PM -0500, Ben Blakely wrote:

Todd,

Excuse the delay. There still seems to be an issue with that scrip,
even when I device a Resolve Action. Ive even tried using the script
with a ticket that is not a “type approval” and still no go. Any
suggestions?

Ben