[rt-users] Set Custom field in template

Jim Brandt jbrandt at bestpractical.com
Tue Mar 4 08:34:03 EST 2014


On 3/4/14 6:13 AM, Jon Witts wrote:
> and the contents of the template "Auto-Close Warning HTML" is as follows:
>
> --------------------------------------
>
> my $CFName = 'Auto-Close Reminder';
> my $DefaultValue = 'TRUE';
>
> unless( $self->Ticket->FirstCustomFieldValue( $CFName ) eq $DefaultValue ) {
> 		my( $st, $msg ) = $self->Ticket->AddCustomFieldValue(
> 					Field => $CFName,
>                                          Value => $DefaultValue,
>                                          RecordTransaction => 1 );
> 	}
>
> Subject: Auto-Close Warning: {$Ticket->Subject}

I think your issue is after the 'unless' where you're calling Ticket on 
$self. In templates the ticket object is available as just $Ticket as in 
the Subject line above. Try switching your $self->Ticket to $Ticket 
anywhere you're calling $self in the template.

More docs on templates are available here:

http://bestpractical.com/docs/rt/latest/customizing/templates.html

You'll also need to put that initial code in some curly braces { } 
inside the template. More info here:

https://metacpan.org/pod/Text::Template

-- 




More information about the rt-users mailing list