Script User Condition help

Ok, I am giving up on this without any PERL expert hints (A BIG ONE). It seems I am able to recreate the RT scrip condition “ON STATUS CHANGE”, but it’s still failing to do what I wish to do.

That is when ticket status set to “resolved” status, I would like the scrip to stop sending out “ON STATUS CHANGE” notifications. Only do it when the ticket is under status. I’ve tried to do a printf and see if there is something wrong $ticket->Status but am unable to get a printf info.

Please help! Thanks!

my $TicketStatusCondition=$self->TransactionObj;
my $ticket = $self->TicketObj;

printf $ticket->Status;

if ($ticket->Status ne ‘resolved’) {
$TicketStatusCondition -> SetExecModule(“AnyTransaction”);
$TicketStatusCondition -> SetApplicableTransTypes(“Status”);
return(1);
}
else {
return(‘undef’);
}

This electronic mail message contains information belonging to PaymentOne, which may be confidential and/or legal privileged. The information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, printing, copying, distribution, or the taking of any action in reliance on the contents of this electronically mailed information is strictly prohibited. If you receive this message in error, please immediately notify us by electronic mail and delete this message.

No one have a clue as to what I did wrong or rather ideas as to how to get this working? :(From: rt-users-bounces@lists.bestpractical.com on behalf of Jonathan Chen
Sent: Wed 7/7/2004 2:00 PM
To: rt-users
Subject: RE: [rt-users] Script User Condition help

Ok, I am giving up on this without any PERL expert hints (A BIG ONE). It seems I am able to recreate the RT scrip condition “ON STATUS CHANGE”, but it’s still failing to do what I wish to do.

That is when ticket status set to “resolved” status, I would like the scrip to stop sending out “ON STATUS CHANGE” notifications. Only do it when the ticket is under status. I’ve tried to do a printf and see if there is something wrong $ticket->Status but am unable to get a printf info.

Please help! Thanks!

my $TicketStatusCondition=$self->TransactionObj;
my $ticket = $self->TicketObj;

printf $ticket->Status;

if ($ticket->Status ne ‘resolved’) {
$TicketStatusCondition → SetExecModule(“AnyTransaction”);
$TicketStatusCondition → SetApplicableTransTypes(“Status”);
return(1);
}
else {
return(‘undef’);
}

This electronic mail message contains information belonging to PaymentOne, which may be confidential and/or legal privileged. The information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, printing, copying, distribution, or the taking of any action in reliance on the contents of this electronically mailed information is strictly prohibited. If you receive this message in error, please immediately notify us by electronic mail and delete this message.

my $tr = $self->TransactionObj;
if ($tr->Field eq ‘Status’ && $tr->NewValue ne ‘resolved’) {
return(1);
} else {
return(‘undef’);
}

Jonathan Chen wrote:

Ok, the code seems not working. Maybe I’ve inserted it in the wrong place of the scrip.

Here is my setting script for RT 3.11

a) Notify on Ticket Status
“User Defined Notify Requestors, Ccs and AdminCcs with template Transaction content”

b)In the “Notify on Ticket Status”, I inserted your code in “Custom condition” with line “Condition” changed to “user defined”.

That’s it and I still get 2 emails sent to the requestor with

  1. “Your ticket has been resolved” template.
  2. “Transaction: Status changed from open to resolved by root” – I only want notifications sent out only when the status is not “resolved”

Thanks for any help you can give…From: Ruslan U. Zakirov [mailto:cubic@acronis.ru]
Sent: Thursday, July 08, 2004 6:47 AM
To: Jonathan Chen
Cc: rt-users
Subject: Re: [rt-users] Script User Condition help

my $tr = $self->TransactionObj;
if ($tr->Field eq ‘Status’ && $tr->NewValue ne ‘resolved’) {
return(1);
} else {
return(‘undef’);
}

Jonathan Chen wrote:

**

No one have a clue as to what I did wrong or rather ideas as to how to
get this working? :frowning:


From: rt-users-bounces@lists.bestpractical.com on behalf of Jonathan Chen
Sent: Wed 7/7/2004 2:00 PM
To: rt-users
Subject: RE: [rt-users] Script User Condition help

Ok, I am giving up on this without any PERL expert hints (A BIG ONE).
It seems I am able to recreate the RT scrip condition “ON STATUS
CHANGE”, but it’s still failing to do what I wish to do.

That is when ticket status set to “resolved” status, I would like the
scrip to stop sending out “ON STATUS CHANGE” notifications. Only do it
when the ticket is under status. I’ve tried to do a printf and see if
there is something wrong $ticket->Status but am unable to get a printf
info.

Please help! Thanks!

==================================================
my $TicketStatusCondition=$self->TransactionObj;
my $ticket = $self->TicketObj;

printf $ticket->Status;

if ($ticket->Status ne ‘resolved’) {
$TicketStatusCondition → SetExecModule(“AnyTransaction”);
$TicketStatusCondition → SetApplicableTransTypes(“Status”);
return(1);
}
else {
return(‘undef’);
}

This electronic mail message contains information belonging to PaymentOne, which may be confidential and/or legal privileged. The information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, printing, copying, distribution, or the taking of any action in reliance on the contents of this electronically mailed information is strictly prohibited. If you receive this message in error, please immediately notify us by electronic mail and delete this message.

Jonathan Chen wrote:

Ok, the code seems not working. Maybe I’ve inserted it in the wrong place of the scrip.

Here is my setting script for RT 3.11

a) Notify on Ticket Status
“User Defined Notify Requestors, Ccs and AdminCcs with template Transaction content”

b)In the “Notify on Ticket Status”, I inserted your code in “Custom condition” with line “Condition” changed to “user defined”.
This steps are OK.
:slight_smile: I’ve found error :)))
it’s ‘undef’, undef is special perl OP, which shouldn’t be qouted :slight_smile:
If we qoute it then condition return string ‘undef’ which is true value.
Copy&Paste error. Sorry.

my $tr = $self->TransactionObj;
if ($tr->Field eq ‘Status’ && $tr->NewValue ne ‘resolved’) {
return 1;
} else {
return undef;
}
Best regards. Ruslan.

Thanks! That worked. I wonder if my previous code would’ve worked if I did “return undef” too.

If I understood your code correctly, the “TransactionObj” holds all the table fields and it should be used most of the time for custom scrips?

Jonathan ChenFrom: Ruslan U. Zakirov [mailto:cubic@acronis.ru]
Sent: Thursday, July 08, 2004 9:10 AM
To: Jonathan Chen
Cc: rt-users
Subject: Re: [rt-users] Script User Condition help

Jonathan Chen wrote:

Ok, the code seems not working. Maybe I’ve inserted it in the wrong place of the scrip.

Here is my setting script for RT 3.11

a) Notify on Ticket Status
“User Defined Notify Requestors, Ccs and AdminCcs with template Transaction content”

b)In the “Notify on Ticket Status”, I inserted your code in “Custom condition” with line “Condition” changed to “user defined”.
This steps are OK.
:slight_smile: I’ve found error :)))
it’s ‘undef’, undef is special perl OP, which shouldn’t be qouted :slight_smile:
If we qoute it then condition return string ‘undef’ which is true value.
Copy&Paste error. Sorry.

my $tr = $self->TransactionObj;
if ($tr->Field eq ‘Status’ && $tr->NewValue ne ‘resolved’) {
return 1;
} else {
return undef;
}
Best regards. Ruslan.

That’s it and I still get 2 emails sent to the requestor with

  1. “Your ticket has been resolved” template.
  2. “Transaction: Status changed from open to resolved by root” – I only want notifications sent out only when the status is not “resolved”

Thanks for any help you can give…

This electronic mail message contains information belonging to PaymentOne, which may be confidential and/or legal privileged. The information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, printing, copying, distribution, or the taking of any action in reliance on the contents of this electronically mailed information is strictly prohibited. If you receive this message in error, please immediately notify us by electronic mail and delete this message.

Jonathan Chen wrote:

Thanks! That worked. I wonder if my previous code would’ve worked if I did “return undef” too.

If I understood your code correctly, the “TransactionObj” holds all the table fields and it should be used most of the time for custom scrips?
In custom code(in both: condition, action) you can use next calls:
my $TransactionObj = $self->TransactionObj;
my $TicketObj = $self->TicketObj;
my $TemplateObj = $self->TemplateObj;

Each object represent record in tables: Transactions, Tickets, Templates.

API docs

basics

perldoc /opt/rt3/lib/RT/Ticket.pm

extended

perldoc /opt/rt3/lib/RT/Ticket_*.pm

You can use perdoc command on any RT modules to read its docs.

			Ruslan.