[rt-users] My User-Defined scrips (examples)

Peter Burkholder peterb at ucar.edu
Mon Apr 28 18:01:32 EDT 2003


I didn't see this covered in the documentation or when I googled over
rt-users, so I thought I'd share this for any one's benefit.

I wasn't pleased with RT3's global scrip, "On Correspond Notify AdminCCs
with Template Admin Correpondence" because it made for too much traffic.
So I deleted that and added, "On Correspond Notify Owner with template 
Correspondence" through the web interface.  I also needed something like,
"On Correspond to Unowned Notify Admin Ccs W Admin Correspondence".  So...

On the Add a scrip page, I used
	- Condition: User-defined
	- Custom Condition:

	if (($self->TransactionObj->Type eq "Correspond") and
	    ($self->TicketObj->OwnerObj->Id == $RT::Nobody->Id)) {
	      return(1);
	} else {
	      return(undef);
	}

	- Action: NotifyAdminCCs
	- Template: Global Template: Admin Correspondence


I also implemented AutoTake as user-defined scrip instead of using the
contribute code:
	- Condition: On Correspond
	- Action: User Defined
	- Custom action preparation code: 

	my $retval = undef;
	if ( defined( $self->TicketObj->OwnerObj->id ) ){
	    if( $self->TicketObj->OwnerObj->Id == $RT::Nobody->Id ){
		$retval = 1;
	    }
	}

	- Custom action cleanup code: 
	my $retval = undef;
	if ($self->TransactionObj->CreatorObj->Privileged &&
	    $self->TransactionObj->CreatorObj->Id != $RT::Nobody->Id ) {
	    if( $self->TransactionObj->CreatorObj->HasRight( Object =>
		$self->TicketObj->QueueObj, Right => 'OwnTicket')) {
		$RT::Logger->info("Autotake ticket");
                # They can own the ticket.  Make it so.
		$retval = $self->TicketObj->SetOwner(
		$self->TransactionObj->CreatorObj->Id );
	    }
	}
	return( $retval );

	- Template: Global Template: Taken [local template]

Hope someone finds this useful.

Cheers,

Peter

--
Peter Burkholder, System Administrator
Digital Library for Earth System Education (DLESE -- http://www.dlese.org)
peterb at ucar.edu
DLESE Program Center (DPC)                             ~~~  ~~  ~~~~   __o
UCAR/DPC, P.O. Box 3000       Ph) 303-497-2663       ~~~  ~~~~ ~~    _`\<,_
Boulder, CO 80307-3000        Fx) 303-497-8336  ~~~~ ~~~   ~~~~     (*)/ (*)



More information about the rt-users mailing list