[rt-users] Placing Custom Fields into the Subject

Kevin Falcone falcone at bestpractical.com
Mon Mar 12 17:05:52 EDT 2012


On Mon, Mar 12, 2012 at 05:00:24PM -0400, Chad Osmond wrote:
> >>    But I'd like to re-write the subject with some of the information contained in the custom fields..
> >>    I assume it's a Scrip, On Create, running after our ExtractCF scrip...
> 
> >Yes, it's an On Create with a User Defined action, Prepare would be 1; and Commit would call $self->TicketObj->SetSubject() passing in the data you want.
> 
> I've created a scrip in the Global and in the Queue itself to try and get this working...
> 
> So far I have: 
> 
> Description:	 " 020 - Set subject based on custom field"
> Condition: 	On Create
> Action:		User Defined
> Template:	Global Template: Blank
> Stage:		Transaction Create
> 

This code is for a User Defined condition, you have a User Defined
action, so you need to delete the code from this box

> Custom Condition:
> $RT::Logger->info("Running Scrip #020 Set Subject");
> my $subject = $self->TicketObj->FirstCustomFieldValue('Address');
> my ($status, $msg) = $self->TicketObj->SetSubject($subject) ;
> unless ( $status ) {
>     $RT::Logger->error("Couldn't change the subject due to: $msg");
>     return 0;
> }
> return 1;
> 
> Custom action prepare code: 
> return 1;


And put it in this box (the cleanup box)

> Custom action cleanup code:
> return 1;
> 
> 
> I set the logging in RT to debug, and I can see the scrip executing after the extraction of custom fields.. (It's #15) but the subject isn't set...

RT will never execute the code in Custom Condition because your
Condition is On Create (which is correct).  RT is executing your
custom action code, which consists only of a true value to indicate
success.

-kevin

>  [info]: CustomFieldValue (Pager, 025 ) added: 237  (/opt/rt4/local/plugins/RT-Extension-ExtractCustomFieldValues/lib/RT/Action/ExtractCustomFieldValues.pm:213)
>  [debug]: Committing scrip #15 on txn #1451 of ticket #194 (/opt/rt4/sbin/../lib/RT/Scrips.pm:192)
>  [debug]: Committing scrip #3 on txn #1451 of ticket #194 (/opt/rt4/sbin/../lib/RT/Scrips.pm:192)
>  [debug]: Committing scrip #4 on txn #1451 of ticket #194 (/opt/rt4/sbin/../lib/RT/Scrips.pm:192)
>  [debug]: Calling SetRecipientDigests for transaction RT::Transaction=HASH(0x7f1ad539b878), id 1451 (/opt/rt4/sbin/../lib/RT/Action/SendEmail.pm:641)
>  [debug]: Working on mailfield To; recipients are  (/opt/rt4/sbin/../lib/RT/Action/SendEmail.pm:657)
>  [debug]: Subject: [RT #194] test 11
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20120312/3e4bd0a5/attachment.sig>


More information about the rt-users mailing list