<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>So here is the code that I am working with inside my template:<br>Script:<br>Condition: On Create<br>Action: Notify Other Recipients<br>Template: My Notify<br>Stage: TransactionBatch<br><br>'My Notify' code<br>-------------------------------------------<br>{<br>my $trans = $self->TransactionObj;<br>my $ticket = $self->TicketObj;<br>my $cf = new RT::CustomField($RT::SystemUser);<br>$cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "Building");<br>return 0 unless $cf->id;<br>my $cfvalue = $ticket->FirstCustomFieldValue('Building');<br><br>my $to_address = "";<br><br>if ($cfvalue =~ /Sheldon/) {<br> $to_address = "sheldonhd";<br>}<br>elsif ($cfvalue =~ /North/) {<br> $to_address = "northhd";<br>}<br>elsif ($cfvalue =~ /South/) {<br> $to_address = "southhd";<br>}<br>elsif ($cfvalue =~ /Churchill/) {<br> $to_address = "churchillhd";<br>}<br>elsif ($cfvalue =~ /Kennedy/) {<br> $to_address = "kennedyhd";<br>}<br>elsif ($cfvalue =~ /Kelly/) {<br> $to_address = "kellyhd";<br>}<br>elsif ($cfvalue =~ /Computer/) {<br> $to_address = "engle";<br>else {<br> $to_address= "rubble";<br>}<br>return 1;<br>}<br><br><br>To: {$to_address}@4j.lane.edu"}<br>Subject: New Ticket #{ $Ticket->Id() } has been created<br><br>Time to go to work<br>----------------------------------<br><br>In my debug log, I am not even seeing the script being called that contains this template. If I strip everything above the 'To:' field, the scrip and template gets called but the e-mail is not sent even when I hard code the e-mail address.<br><br><br><span><br><span name="x"></span>Kurt Engle<br></span><br><hr id="zwchr"><b>From: </b>"Kevin Falcone" <falcone@bestpractical.com><br><b>To: </b>rt-users@lists.bestpractical.com<br><b>Sent: </b>Friday, December 10, 2010 12:23:28 PM<br><b>Subject: </b>Re: [rt-users] notification<br><br>On Fri, Dec 10, 2010 at 12:08:05PM -0800, Kenneth Crocker wrote:<br>> Kevin,<br>> The template would look like this:<br><br>Kenn<br><br>I'm perfectly able to write the scrip and template in question, but<br>since Kurt has a half-working template I was curious what *he* was<br>doing. Involving a CustomField seems like a bit of overkill.<br><br>-kevin<br><br>> To: {$Ticket->FirstCustomFieldValue('ToOverride')}@[1]lbl.gov<br>> Subject: Request Titled: "{$Ticket->Subject}" is ready to Migrate!<br>> <br>> A scrip based on whatever condition would do this:<br>> <br>> my $trans = $self->TransactionObj;<br>> my $ticket = $self->TicketObj;<br>> my $cf_obj = new RT::CustomField($RT::SystemUser);<br>> my $cf_name = "ToOverride";<br>> <br>> if condition is "A"<br>> $my $cf_value = "the To address you want for "A" condition";<br>> elsif condition is "B"<br>> $my $cf_value = "the To address you want for "B" condition";<br>> <br>> and on and on till you're thru.<br>> <br>> then, set the Custom Field as the last piece of action code:<br>> <br>> $cf_obj->LoadByName(Name=>$cf_name);<br>> $RT::Logger->debug("Loaded\$cf_obj->Name = ". $cf_obj->Name() ."\n" );<br>> $ticket->AddCustomFieldValue( Field=>$cf_obj, Value=>$cf_value, RecordTransaction=>0 );<br>> <br>> return 1;<br>> <br>> Then write a notification scrip to use the new template based on your conditions.<br>> Use "TransactioBatch" for both scrips.<br>> <br>> Hope this helps.<br>> <br>> Kenn<br>> LBNL<br>> <br>> On Fri, Dec 10, 2010 at 11:55 AM, Kevin Falcone <[2]falcone@bestpractical.com> wrote:<br>> <br>> On Fri, Dec 10, 2010 at 11:07:32AM -0800, Kurt Engle wrote:<br>> > Actually found a nice example of creating a template to send out an e-mail. RTFM....<br>> ><br>> > However, I am having a bit of a problem constructing the To: field. Basically, I have a<br>> > varialble '$toAddress' that is set to an e-mail address by some prior code.<br>> <br>> Where in the code is it set. It would really need to be in that<br>> template<br>> > Here is my template code to construct the To: field:<br>> > To: { $toAddress }<br>> > Subject: Ticket #{ $Ticket->Id()} {$Ticket->Subject()}<br>> > A new ticket has been created for you in the HelpDesk Queue.<br>> ><br>> > { $RT::WebURL } Ticket/Display.html?id={ $Ticket->Id() }<br>> ><br>> > However, I keep getting 'recipient not found'.<br>> <br>> In debug logging mode, RT will actually dump copies of the email being<br>> processed into the logs, which would show you the To:<br>> <br>> Please note that if To: is your email address and you're the actor on<br>> this ticket while testing, you may have told RT not to send you email<br>> in that case using $NotifyActor<br>> -kevin<br>> <br>> ><br>> ----------------------------------------------------------------------------------------------<br>> ><br>> > From: "Kevin Falcone" <[3]falcone@bestpractical.com><br>> > To: [4]rt-users@lists.bestpractical.com<br>> > Sent: Friday, December 10, 2010 10:03:04 AM<br>> > Subject: Re: [rt-users] notification<br>> ><br>> > On Fri, Dec 10, 2010 at 09:55:07AM -0800, Kurt Engle wrote:<br>> > > That is correct. But how do I make use of the RT::Action::SendEmail module to send the<br>> > > notification incorporating my To: field. Or is there a better way to send out a custom<br>> > > notification?<br>> ><br>> > You use one of the standard Notify actions and a custom template. You<br>> > don't write any code in the action and you don't call the action<br>> > directly.<br>> ><br>> > -kevin<br>> ><br>> > > From: "Kevin Falcone" <[5]falcone@bestpractical.com><br>> > > To: [6]rt-users@lists.bestpractical.com<br>> > > Sent: Friday, December 10, 2010 8:59:25 AM<br>> > > Subject: Re: [rt-users] notification<br>> > ><br>> > > On Thu, Dec 09, 2010 at 11:42:03AM -0800, Kurt Engle wrote:<br>> > > > I am looking for a way to send an email from RT to a specified e-mail address that<br>> > is not<br>> > > an<br>> > > > account in RT or associated with the ticket as a requestor, watcher, CC:,<br>> > BCC:...etc....<br>> > > ><br>> > > > I have the logic down to specify the e-mail address and have some nasty perl code to<br>> > > actually<br>> > > > send the e-mail. But, it seems that RT has some internal module(s) that handle what<br>> > the<br>> > > nasty<br>> > > > perl code is doing.<br>> > > ><br>> > > > I can see the RT::Action:SendEmail module, but how do I incorporate that into a<br>> > script<br>> > > that<br>> > > > allows me to do what I am looking to do?<br>> > ><br>> > > Sounds like you actually just want to use a normal Notify action, but<br>> > > have the template contain your ugly logic that sets up the To: line<br>> > > based on your perl code<br>> > ><br>> > > -kevin<br>> <br>> References<br>> <br>> Visible links<br>> 1. http://lbl.gov/<br>> 2. mailto:falcone@bestpractical.com<br>> 3. mailto:falcone@bestpractical.com<br>> 4. mailto:rt-users@lists.bestpractical.com<br>> 5. mailto:falcone@bestpractical.com<br>> 6. mailto:rt-users@lists.bestpractical.com<br></div></body></html>