NotifyOwner and NotifyOwnerAsComment

Hi,

I’m not sure if i’m posting this on the right place, if so tell me where i
should have posted.

I’m having i little problem with NotifyOwner and NotifyOwnerAsComment on RT
2.0.15, I created these 2 scrips and it’s working in some way but I
discovered that when RT receive a new Ticket and click on “Comment” or
"Reply" link write the message and set a new Owner, this new owner that i
just set don’t receive anything but any comment or reply done after this,
the owner receives without problems. Why the Owner don’t receive in the
first time i set it? How can I change that?

I also tried to look at the list archives but I didn’t find anything.

bye.

Rafael Máximo

Hi,

I’m having i little problem with NotifyOwner and NotifyOwnerAsComment on RT
2.0.15, I created these 2 scrips and it’s working in some way but I
discovered that when RT receive a new Ticket and click on “Comment” or
"Reply" link write the message and set a new Owner, this new owner that i
just set don’t receive anything but any comment or reply done after this,
the owner receives without problems. Why the Owner don’t receive in the
first time i set it? How can I change that?

I also tried to look at the list archives but I didn’t find anything.

bye.

Rafael Máximo

Rafael Maximo wrote:

I’m having i little problem with NotifyOwner and NotifyOwnerAsComment on RT
2.0.15, I created these 2 scrips and it’s working in some way but I
discovered that when RT receive a new Ticket and click on “Comment” or
“Reply” link write the message and set a new Owner, this new owner that i
just set don’t receive anything but any comment or reply done after this,
the owner receives without problems. Why the Owner don’t receive in the
first time i set it? How can I change that?

The comment transaction is processed before the Owner is changed.
There’s possibly a way to force this to happen in the opposite
order, but I haven’t looked at that part of the code.

You could work around this by installing OnOwnerChange from the
contrib area, and doing an OnOwnerChange NotifyOwner.
Phil Homewood, Systems Janitor, www.SnapGear.com
pdh@snapgear.com Ph: +61 7 3435 2810 Fx: +61 7 3891 3630
SnapGear - Custom Embedded Solutions and Security Appliances

At 09:22 PM 16/1/2003, you wrote:

Rafael Maximo wrote:

I’m having i little problem with NotifyOwner and NotifyOwnerAsComment
on RT
2.0.15, I created these 2 scrips and it’s working in some way but I
discovered that when RT receive a new Ticket and click on “Comment” or
“Reply” link write the message and set a new Owner, this new owner that i
just set don’t receive anything but any comment or reply done after this,
the owner receives without problems. Why the Owner don’t receive in the
first time i set it? How can I change that?

The comment transaction is processed before the Owner is changed.
There’s possibly a way to force this to happen in the opposite
order, but I haven’t looked at that part of the code.

You could work around this by installing OnOwnerChange from the
contrib area, and doing an OnOwnerChange NotifyOwner.

It worked but not in the way a wanted. I want the new owner to receive the
comment or the reply. Let me explain what happen here, The RT receives the
new ticket and then a read and click on comment, write the comment and set
the owner responsible to answer that ticket, but a want the new owner to
receive the comment in his e-mail. With your suggestion the owner is being
notified but he doesn’t receive the comment.

Is there any way to do that?


Phil Homewood, Systems Janitor, www.SnapGear.com
pdh@snapgear.com Ph: +61 7 3435 2810 Fx: +61 7 3891 3630
SnapGear - Custom Embedded Solutions and Security Appliances


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

Rafael Máximo

You could work around this by installing OnOwnerChange from the
contrib area, and doing an OnOwnerChange NotifyOwner.

It worked but not in the way a wanted. I want the new owner to receive the
comment or the reply. Let me explain what happen here, The RT receives the
new ticket and then a read and click on comment, write the comment and set
the owner responsible to answer that ticket, but a want the new owner to
receive the comment in his e-mail. With your suggestion the owner is being
notified but he doesn’t receive the comment.

You want to modify the template to send the old comment, not just the
current transaction. (ie {$Transaction->Content()} )

See below for one example template… this doesn’t show actions, such as
who reassigned to who, if someone wants to modify it, please share the
improved code with me (and all of us).

Greetings, this ticket is now yours.

— The initial request was -----------------------------------

{$Ticket->Transactions->First->Content()}

— Additional activity ----------------------------------------

{
my $this_transaction;
my $complete_message = “”;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy;
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
if (!$Transactions->IsLast) {
$this_transaction = undef;
}

if ($this_transaction) {

my $attachments = $this_transaction->Attachments;
$attachments->GotoFirstItem;

while (my $message = $attachments->Next) {
  next unless $message->ContentType =~
m!^(text/plain|message|text$)!i;

  my $content = $message->Content;
  next unless length $content;

  my $subject = ($message->Subject || $Ticket->Subject);

  my $wrapper = Text::Wrapper->new(columns=>70);
  $content = $wrapper->wrap($content);

  $complete_message .= "Subject: ";
  $complete_message .= $subject;
  $complete_message .= "\n";
  $complete_message .= "From: ";
  $complete_message .= $message->CreatorObj->RealName;
  $complete_message .= "\n";
  $complete_message .= "Time: ";
  $complete_message .= $message->CreatedObj->AsString;
  $complete_message .= "\n";
  $complete_message .= "\n";
  $complete_message .= "$content\n";
  $complete_message .= "--------------------------\n";
}

}
}

$complete_message;
}

Oops… missed a line in the cut and paste. Sorry about that.
Didn’t notice it until I’d sent it off.

Correction:

$Transactions->OrderBy;
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {

 $this_transaction = $Transaction;

        if (!$Transactions->IsLast) {      
       $this_transaction = undef;
        }

Add the missing line as above.

Complete template again for those who want to cut and paste:

Greetings, this ticket is now yours.

— The initial request was ------------------------------------

{$Ticket->Transactions->First->Content()}

— Additional activity ----------------------------------------

{
my $this_transaction;
my $complete_message = “”;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy;
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
$this_transaction = $Transaction;
if (!$Transactions->IsLast) {
$this_transaction = undef;
}

if ($this_transaction) {

my $attachments = $this_transaction->Attachments;
$attachments->GotoFirstItem;

while (my $message = $attachments->Next) {
  next unless $message->ContentType =~
m!^(text/plain|message|text$)!i;

  my $content = $message->Content;
  next unless length $content;

  my $subject = ($message->Subject || $Ticket->Subject);

  my $wrapper = Text::Wrapper->new(columns=>70);
  $content = $wrapper->wrap($content);

  $complete_message .= "Subject: ";
  $complete_message .= $subject;
  $complete_message .= "\n";
  $complete_message .= "From: ";
  $complete_message .= $message->CreatorObj->RealName;
  $complete_message .= "\n";
  $complete_message .= "Time: ";
  $complete_message .= $message->CreatedObj->AsString;
  $complete_message .= "\n";
  $complete_message .= "\n";
  $complete_message .= "$content\n";
  $complete_message .= "--------------------------\n";
}

}
}

$complete_message;
}

One MORE correction. Bleh.

I’d modified this template and halfway tested it, but didn’t notice that
I’d goofed. The original version of this template was for resolved
tickets, and was sent to the end user, so it stripped out everything but
correspondence. This version was for sending to the new owner, so I wanted
comments sent. But I messed up the if/elsif lines, and never noticed
that. Please excuse my error(s).

Use the following, which works, which I’ve tested fully now.
I’d love to see the code that would process the non-message transactions
properly, if anyone does take the time to write that.

Greetings, this ticket is now yours.

   Queue: {$Ticket->QueueObj->Name}

Requestors: {$Ticket->Requestors->EmailsAsString()}
Status: {$Ticket->Status}
Ticket <URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} >

— The initial request was ------------------------------------

{$Ticket->Transactions->First->Content()}

— Additional activity ----------------------------------------

{
my $this_transaction;
my $complete_message = “”;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy;
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
$this_transaction = $Transaction;
if ($this_transaction) {

  my $attachments = $this_transaction->Attachments;
  $attachments->GotoFirstItem;

  while (my $message = $attachments->Next) {
    next unless $message->ContentType =~

m!^(text/plain|message|text$)!i;

    my $content = $message->Content;
    next unless length $content;

    my $subject = ($message->Subject || $Ticket->Subject);

    my $wrapper = Text::Wrapper->new(columns=>70);
    $content = $wrapper->wrap($content);

    $complete_message .= "Subject: ";
    $complete_message .= $subject;
    $complete_message .= "\n";
    
    $complete_message .= "From: ";
    $complete_message .= $message->CreatorObj->RealName;
    $complete_message .= "\n";
    
    $complete_message .= "Time: ";
    $complete_message .= $message->CreatedObj->AsString;
    $complete_message .= "\n";
    
    $complete_message .= "\n";
    $complete_message .= "$content\n";
    $complete_message .= "--------------------------\n";
  
    }
 }

}

$complete_message;

}

Thank you a lot, it worked just great, exactly what I wanted.

Thanks for your help.

bye.
At 01:26 AM 17/1/2003, you wrote:

One MORE correction. Bleh.

I’d modified this template and halfway tested it, but didn’t notice that
I’d goofed. The original version of this template was for resolved
tickets, and was sent to the end user, so it stripped out everything but
correspondence. This version was for sending to the new owner, so I wanted
comments sent. But I messed up the if/elsif lines, and never noticed
that. Please excuse my error(s).

Use the following, which works, which I’ve tested fully now.
I’d love to see the code that would process the non-message transactions
properly, if anyone does take the time to write that.


Subject: Ticket Reassigned: {$Ticket->Subject}

Greetings, this ticket is now yours.

   Queue: {$Ticket->QueueObj->Name}

Requestors: {$Ticket->Requestors->EmailsAsString()}
Status: {$Ticket->Status}
Ticket <URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} >


— The initial request was ------------------------------------

{$Ticket->Transactions->First->Content()}


— Additional activity ----------------------------------------

{
my $this_transaction;
my $complete_message = “”;
my $Transactions = $Ticket->Transactions;
$Transactions->OrderBy;
$Transactions->GotoFirstItem;
while (my $Transaction = $Transactions->Next) {
$this_transaction = $Transaction;
if ($this_transaction) {

  my $attachments = $this_transaction->Attachments;
  $attachments->GotoFirstItem;

  while (my $message = $attachments->Next) {
    next unless $message->ContentType =~

m!^(text/plain|message|text$)!i;

    my $content = $message->Content;
    next unless length $content;

    my $subject = ($message->Subject || $Ticket->Subject);

    my $wrapper = Text::Wrapper->new(columns=>70);
    $content = $wrapper->wrap($content);

    $complete_message .= "Subject: ";
    $complete_message .= $subject;
    $complete_message .= "\n";

    $complete_message .= "From: ";
    $complete_message .= $message->CreatorObj->RealName;
    $complete_message .= "\n";

    $complete_message .= "Time: ";
    $complete_message .= $message->CreatedObj->AsString;
    $complete_message .= "\n";

    $complete_message .= "\n";
    $complete_message .= "$content\n";
    $complete_message .= "--------------------------\n";

    }
 }

}

$complete_message;

}


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

Rafael Máximo

Hi,

I’d love to see the code that would process the non-message
transactions properly, if anyone does take the time to write that.

I am not 100% sure, what you ment, but this is what I use. You can
change the next unless line:

— start here —

{my $transactions = $Ticket->Transactions;
$transactions->OrderBy(FIELD => ‘Created’, ORDER => ‘DESC’);
while (my $trans = $transactions->Next) {
next unless ($trans->Type =~ /^(Create|Correspond|Escalation$)/);
$OUT .= $trans->CreatedObj->AsString . “: " .
$trans->Description;
if ($trans->TimeTaken) {$OUT .= " (”.$trans->TimeTaken." min)";}
$OUT .= “\n”;
if ($trans->Content) {$OUT .= $trans->Content . “\n”;}
$OUT .=
“-----------------------------------------------------------------------
------\n”;
}

1;
}

— stop here —

cu,
Julian