[rt-users] setting ticket owner automatically

Alex Harrington alex at longhill.brighton-hove.sch.uk
Thu Jun 30 20:52:53 EDT 2005


> I'd like to set a scrip that sets the owner to that user on creation.

Create a new scrip for that queue as follows:

Condition: OnCreate
Action: User Defined
Template: Global template: Blank
Stage: Transaction Create
Custom Condition:
Custom action prep. code: return 1;
Custom action cleanup code:

  # get actor ID
  my $User = new RT::User($RT::SystemUser);

  # Put the email address of the user who needs to own tickets in this
queue in here!
  $User->LoadByEmail("user\@domain.tld");  

  my $Actor = $User->id;

  # if actor is RT_SystemUser then get out of here
  return 1 if $Actor == $RT::SystemUser->id;

  # get out unless ticket owner is nobody
  return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;

  # ok, try to change owner
  $RT::Logger->info("Auto assign ticket #". $self->TicketObj->id ." to
user #". $Actor );
  my ($status, $msg) = $self->TicketObj->SetOwner( $Actor );
  unless( $status ) {
    $RT::Logger->warning( "Impossible to assign tickt to $Actor: $msg"
);
    return undef;
  }
  return 1;

Hope that's helpful.

Cheers

-- 
Alex Harrington - IT Support, Longhill High School

t: 01273 304086 | e: alex at longhill.org.uk




More information about the rt-users mailing list