Is it possible at all to debug the code somehow? It's tough to debug as I'm not able to get any output back from RT. If there is somewhere I can enable logs for this, that'd be great. Here's my latest revision with Stephen's suggestions. I'll pin point the line which causes the code to fail. If I remove it, it assigns the ticket to whoever last corresponds. However, I need it to not assign based if two individual users make a correspondance. Those users are "foo" and "bar".
<br><br>my $Actor = $self->TransactionObj->CreatorObj->Name;<br><br>return 1 if ( $Actor == "foo" || $Actor == "bar"); # This is the line that's causing the Scrip to fail. No one gets assigned a ticket.
<br>return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;<br>$RT::Logger->info("Auto assign ticket #". $self->TicketObj->id ." to user #". $Actor );<br>my ($status, $msg) = $self->TicketObj->SetOwner( $Actor );
<br>unless ( $status ) {<br> $RT::Logger->error( "Impossible to assign the ticket to $Actor: $msg" );<br> return undef;<br>}<br>return 1;<br><br>Thanks again everyone for your help.<br><br>-- Steve<br><div>
<span class="gmail_quote">On 10/11/06, <b class="gmail_sendername">Stephen Turner</b> <<a href="mailto:sturner@mit.edu">sturner@mit.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br><br> I'm trying to automatically assign tickets whenever someone either<br><br> a) comments a ticket or alternatively,<br> b) responds to a ticket<br><br> The conditions are that the current owner is Nobody and the user
<br>cannot be user 'X' (my supervisor for instance, might post comments on a<br>ticket first, but he's the boss and we want to exclude him from getting<br>ownership.) Here's the Scrip I put together thus far. If anyone can shed
<br>some light, that'd be great!<br><br> PS: If there is a better forum for me to post this on, I'd be more<br>than happy to not waste any of your bandwidth and go there.<br><br> Description: Ticket Auto Assign
<br> Condition: On Comment (I'm not sure how to get On Comment AND On<br>reply at the same time? Need two different Scrips?)<br> Action: User Defined<br> Template: Global Template: Transaction (I'm not sure what this does,
<br>need to look it up on the Wiki)<br> Stage: Disabled (No idea what this one does either ..)<br> Custom Condition:<br> Custom Action Preparation Code:<br><br> my $notOwner = "billybob"; # I don't want billybob to get assigned
<br>any tickets no matter if he replies first<br> my $Actor = $self->TransactionObj->Creator;<br><br> return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;<br> $RT::Logger->info("Auto assign ticket #". $self->TicketObj->id ." to
<br>user #". $Actor );<br> my ($status, $msg) = $self->TicketObj->SetOwner( $Actor ) unless<br>$Actor == $notOwner;<br> unless ( $status ) {<br> $RT::Logger->error( "Impossible to assign the ticket to $Actor:
<br>$msg" );<br> return undef;<br> }<br> return 1;<br> Custom action cleanup code: return 1;<br><br> This doesn't look to do the trick. Any suggestions again, would be<br>more than appreciated.
<br><br> Thanks all!<br> --<br> Steve<br><br>------------------------------------------<br>Hi Steve,<br><br>This is exactly the right forum!<br><br>You don't mention what's actually happening - in what way is this failing?
<br>Are there error messages in the RT log when this scrip is activated? Or does<br>it just silently not do what you want?<br><br>To have the scrip respond to either a comment or a reply, you could use a<br>custom/user-defined condition that checks the transaction type - relevant
<br>values are 'Comment' and 'Correspond'.<br><br>For scrips that don't need to send email, you should use the Blank template.<br><br>I did notice one thing in the code: "unless $Actor == $notOwner". This won't<br>
work, as $Actor is an Id number whereas $notOwner is a user name (string).<br>You can get the user name of the "actor" by doing<br>$self->TransactionObj->CreatorObj->Name.<br><br>Good luck,<br>Steve<br>
<br>----------------------------------------<br>Stephen Turner<br>Senior Programmer/Analyst - Client Support Services<br>MIT Information Services and Technology (IS&T)<br><br><br><br><br><br></blockquote></div><br>