[rt-users] Action Upon Approval 11 messages Ben Blakely Monday, December 13, 2004 11:55:41 AM GMT-05:00 To: rt-users@lists.bestpractical.com 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 _______________________________________________ Todd Chapman Monday, December 13, 2004 1:11:49 PM GMT-05:00 To: Ben Blakely Cc: rt-users@lists.bestpractical.com 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; [Quoted text hidden] _______________________________________________ Todd Chapman Monday, December 13, 2004 2:33:22 PM GMT-05:00 To: Ben Blakely Cc: rt-users@lists.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. -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 [Quoted text hidden] _______________________________________________ Ben Blakely Monday, December 13, 2004 3:38:49 PM GMT-05:00 To: Todd Chapman Cc: rt-users@lists.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. Ben [Quoted text hidden] _______________________________________________ Todd Chapman Monday, December 13, 2004 3:07:46 PM GMT-05:00 To: Ben Blakely Cc: rt-users@lists.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 > [Quoted text hidden] _______________________________________________ Ben Blakely Monday, December 13, 2004 4:56:56 PM GMT-05:00 To: Todd Chapman Cc: rt-users@lists.bestpractical.com 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. [Quoted text hidden] _______________________________________________ Todd Chapman Monday, December 13, 2004 4:24:36 PM GMT-05:00 To: Ben Blakely Cc: rt-users@lists.bestpractical.com 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. > > [Quoted text hidden] _______________________________________________ Ben Blakely Monday, December 13, 2004 8:41:51 PM GMT-05:00 To: Todd Chapman Cc: rt-users@lists.bestpractical.com 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 [Quoted text hidden] Todd Chapman Tuesday, December 14, 2004 9:04:26 AM GMT-05:00 To: Ben Blakely Cc: rt-users@lists.bestpractical.com 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 [Quoted text hidden] _______________________________________________ Ben Blakely Thursday, December 16, 2004 4:00:02 PM GMT-05:00 To: Todd Chapman Cc: rt-users@lists.bestpractical.com 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 [Quoted text hidden] _______________________________________________ Todd Chapman Thursday, December 16, 2004 3:27:59 PM GMT-05:00 To: Ben Blakely Cc: rt-users@lists.bestpractical.com Start adding/uncommenting debug statements and figure out where things are going wrong. let me know what you find. -Todd On 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 [Quoted text hidden]