Re: [rt-users] Notify via SMS if ticket Subject =~ /urgent/i

2013-07-28 Thread Craig Ringer
On 07/26/2013 01:15 AM, EJ Marmonti wrote:
 Greetings
 
 I'm using RT 4.0.10 and am trying to create a scrip to accomplish this. 
 If the subject contains the word urgent (not case senstive, thus the
 /urgent/i), I want it to send me an SMS.

I've already written one; grab RT::Extension::SMSNotify from CPAN.

-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training  Services


Re: [rt-users] Notify via SMS if ticket Subject =~ /urgent/i

2013-07-28 Thread Craig Ringer
On 07/29/2013 09:34 AM, Craig Ringer wrote:
 On 07/26/2013 01:15 AM, EJ Marmonti wrote:
 Greetings

 I'm using RT 4.0.10 and am trying to create a scrip to accomplish this. 
 If the subject contains the word urgent (not case senstive, thus the
 /urgent/i), I want it to send me an SMS.
 
 I've already written one; grab RT::Extension::SMSNotify from CPAN.

... and combine it with a simple user-defined condition, something like

return $self-Ticket-Subject =~ qr/urgent/i;

-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training  Services


Re: [rt-users] Notify via SMS if ticket Subject =~ /urgent/i

2013-07-26 Thread Kevin Falcone
On Thu, Jul 25, 2013 at 01:15:33PM -0400, EJ Marmonti wrote:
The portion of sending the SMS message itself I figured out so that's less 
 of a concern - in
the template, I just CC the sms address (if Action=Notify AdminCCs', this 
 works), though I am
open to other suggestions. It's the scrip itself that I'm really having 
 issues with.
 
What I have so far:
 
Description: On create URGENT, notify SMS
Condition: On Transaction
Action: User Defined
Template: On Create Urgent ticket, notify SMS
Stage: TransactionCreate

If you have an Action of User Defined, your Template isn't going to be
used unless you're loading it up and sending mail manually.

It sounds to me like you actually wanted
Condition: User Defined
Action: Notify Other Recipieints or Notify Ccs or a custom notify
action created with
http://bestpractical.com/docs/rt/latest/rt-email-group-admin.html

You can combine your Custom action prep code and Custom action cleanup
code into that condition, although I am a little confused.  You
apparently only want to check the subject if the status of the ticket
changes (rather than say when the ticket is created?) but that may be
what you wanted.

-kevin

===Custom condition: n/a
 
===Custom action prep code:
my $txn = $self-TransactionObj;
my $type = $txn-Type;
return 0 unless $type eq Status
|| ( $type eq 'Set'  $txn-Field eq 'Status');
 
return 0 unless $txn-NewValue eq new;
 
===Custom action cleanup code:
 
my $subject = $self-TicketObj-Subject;
 
if ($subject =~ /urgent/i) {
return 1;
}
else {
return 0;
}
 
I found some decent references out there, but this isn't sending the 
 notification and I'm
stumped. I know there are many people out there who have done the 
 equivalent of what I'm
trying to accomplish.
 
Thanks


pgpOM6VvSOx93.pgp
Description: PGP signature


Re: [rt-users] Notify via SMS if ticket Subject =~ /urgent/i

2013-07-26 Thread EJ Marmonti
Kevin:

Unfortunately following your suggestion didn't help.

The reason I check for a status change = new (rather than Condition=On
Create) is because the latter will send me an SMS everytime any ticket is
opened, regardless of the subject contents (as I would expect it to do
given that it says to *Use these fields when you choose 'User Defined' for
a condition or action).

*So what I'm not sure of is if I have a fundamental misunderstanding of how
this is supposed to work, or perhaps something with the way I'm trying to
search for the word 'urgent' in the subject is not correct - ie: where
should that bit of code go if Condition=On Create?

For what I'm trying to accomplish, might it be better to create a custom
Condition?
ie:

rt-setup-database --action insert --datafile
/usr/local/rt/lib/RT/Condition/Foo.pm?

In that case, should it in theory show up as an available action from the
drop-down of available actions?


Thanks




Date: Fri, 26 Jul 2013 08:52:37 -0400
From: Kevin Falcone falc...@bestpractical.com
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Notify via SMS if ticket Subject =~ /urgent/i
Message-ID: 20130726125237.gr22...@jibsheet.com
Content-Type: text/plain; charset=us-ascii

On Thu, Jul 25, 2013 at 01:15:33PM -0400, EJ Marmonti wrote:
The portion of sending the SMS message itself I figured out so that's
less of a concern - in
the template, I just CC the sms address (if Action=Notify AdminCCs',
this works), though I am
open to other suggestions. It's the scrip itself that I'm really
having issues with.

What I have so far:

Description: On create URGENT, notify SMS
Condition: On Transaction
Action: User Defined
Template: On Create Urgent ticket, notify SMS
Stage: TransactionCreate

If you have an Action of User Defined, your Template isn't going to be
used unless you're loading it up and sending mail manually.

It sounds to me like you actually wanted
Condition: User Defined
Action: Notify Other Recipieints or Notify Ccs or a custom notify
action created with
http://bestpractical.com/docs/rt/latest/rt-email-group-admin.html

You can combine your Custom action prep code and Custom action cleanup
code into that condition, although I am a little confused.  You
apparently only want to check the subject if the status of the ticket
changes (rather than say when the ticket is created?) but that may be
what you wanted.

-kevin

===Custom condition: n/a

===Custom action prep code:
my $txn = $self-TransactionObj;
my $type = $txn-Type;
return 0 unless $type eq Status
|| ( $type eq 'Set'  $txn-Field eq 'Status');

return 0 unless $txn-NewValue eq new;

===Custom action cleanup code:

my $subject = $self-TicketObj-Subject;

if ($subject =~ /urgent/i) {
return 1;
}
else {
return 0;
}

I found some decent references out there, but this isn't sending the
notification and I'm
stumped. I know there are many people out there who have done the
equivalent of what I'm
trying to accomplish.

Thanks
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 235 bytes
Desc: not available
URL: 
http://lists.bestpractical.com/pipermail/rt-users/attachments/20130726/e4266325/attachment-0001.pgp



Re: [rt-users] Notify via SMS if ticket Subject =~ /urgent/i

2013-07-26 Thread Kevin Falcone
Please obey the Reply-To.  Sending me personal mail when I read the
list is rude.

On Fri, Jul 26, 2013 at 03:54:43PM -0400, EJ Marmonti wrote:
Unfortunately following your suggestion didn't help.

Except you didn't follow my suggestions.

The reason I check for a status change = new (rather than Condition=On 
 Create) is because the
latter will send me an SMS everytime any ticket is opened, regardless of 
 the subject contents
(as I would expect it to do given that it says to Use these fields when 
 you choose 'User
Defined' for a condition or action).
 
So what I'm not sure of is if I have a fundamental misunderstanding of how 
 this is supposed to
work, or perhaps something with the way I'm trying to search for the word 
 'urgent' in the
subject is not correct - ie: where should that bit of code go if 
 Condition=On Create?

You're misunderstanding how this is supposed to work.

You're writing a custom action that checks a condition and then does
nothing.

Instead, write a custom condition that checks your condition and then
use the build in notification actions.

 It sounds to me like you actually wanted
 Condition: User Defined
 Action: Notify Other Recipieints or Notify Ccs or a custom notify
 action created with
 [4]http://bestpractical.com/docs/rt/latest/rt-email-group-admin.html

-kevin


pgprSueUdANwr.pgp
Description: PGP signature