Assign Owner From Specific Subject - Zero Perl Background

Hi! The forum posts on this seem to be from 2010 and earlier, and although I’ve tried them all, I can’t get them to work and I’m wondering if they’re slightly out of date.

Here’s what I’ve got so far.

Custom condition:

Do not modify below this

my $trans = $self->TransactionObj;
return 0 unless $trans->Type eq “Create”;

my $t_subject = $self->TicketObj->Subject;
if ( $t_subject !~ /TEST111/i ) {
return 1;
}
else {
return 0;
}

Custom action preparation code:

return 1;

Custom action commit code:

Here’s where I think I’m way off base. If my first 2 sections look OK, can anyone suggest how to write the 3rd?

I would suggest using the “On Create” condition provided and then add your check for the ticket subject to the action preparation code.

Custom action preparation code:

return 0 unless $self->TicketObj->Subject =~ /TEST/;

return 1;

Custom action commit code:

my ($ret, $msg) = $self->TicketObj->SetOwner('Owner Name or ID');
RT::Logger->error($msg) unless $ret;

return $ret;

Thanks! I still had some difficulty, unfortunately. I consulted with someone I know with a Perl background, and this is working.

Description: ******* Yr Title Here ********
Condition: On Create
Action: User Defined
Template: Blank

User Defined conditions and results:

Custom condition:

my $trans = $self->TransactionObj;

if( $trans->Type eq ‘Create’ ) {
my $t_subject = $self->TicketObj->Subject;

if ( $t_subject !~ /SAMPLE/i ) {
    return 1;
} else {
    return 0;
}

} else {
return 0;
}

Custom action preparation code:

if ( $self->TicketObj->Subject =~ /SAMPLE/ )
{
return 1;
} else {
return( 0 );
}

Custom action commit code:

my ($ret, $msg) = $self->TicketObj->SetOwner(‘SAMPLE’);

if( !$ret ) {
RT::Logger->error($msg)
}

return $ret;