<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=AddCustomFieldsValuesToMail</id>
	<title>AddCustomFieldsValuesToMail - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=AddCustomFieldsValuesToMail"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AddCustomFieldsValuesToMail&amp;action=history"/>
	<updated>2026-08-21T20:02:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=AddCustomFieldsValuesToMail&amp;diff=40&amp;oldid=prev</id>
		<title>Admin: 2 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AddCustomFieldsValuesToMail&amp;diff=40&amp;oldid=prev"/>
		<updated>2016-04-06T20:03:12Z</updated>

		<summary type="html">&lt;p&gt;2 revisions imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This [[Template]] part adds ticket custom field values to mail.&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
  # old RT versions may be need:&lt;br /&gt;
  # my $CustomFields = $Ticket-&amp;amp;gt;QueueObj-&amp;amp;gt;CustomFields();&lt;br /&gt;
  my $CustomFields = $Ticket-&amp;amp;gt;QueueObj-&amp;amp;gt;TicketCustomFields();&lt;br /&gt;
  while (my $CustomField = $CustomFields-&amp;amp;gt;Next()) {&lt;br /&gt;
    my $CustomFieldValues=$Ticket-&amp;amp;gt;CustomFieldValues($CustomField-&amp;amp;gt;Id);&lt;br /&gt;
    $OUT .= $CustomField-&amp;amp;gt;Name;&lt;br /&gt;
    if ($CustomFieldValues-&amp;amp;gt;Count) {&lt;br /&gt;
      my $spacer;&lt;br /&gt;
       if ( $CustomField-&amp;amp;gt;Type ne &amp;#039;FreeformMultiple&amp;#039; and&lt;br /&gt;
           $CustomField-&amp;amp;gt;Type ne &amp;#039;SelectMultiple&amp;#039; ) {&lt;br /&gt;
        $spacer = &amp;quot; &amp;quot; x (20 - length($CustomField-&amp;amp;gt;Name));&lt;br /&gt;
      } else {&lt;br /&gt;
        $spacer = &amp;quot;\n&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      $OUT .= &amp;quot;:&amp;quot; . $spacer;&lt;br /&gt;
    } else {&lt;br /&gt;
      $OUT .= &amp;quot;:\n&amp;quot;;&lt;br /&gt;
      next;&lt;br /&gt;
    }&lt;br /&gt;
    while (my $CustomFieldValue = $CustomFieldValues-&amp;amp;gt;Next) {&lt;br /&gt;
      $OUT .= &amp;quot; &amp;quot; if ( $CustomField-&amp;amp;gt;Type eq &amp;#039;FreeformMultiple&amp;#039; or&lt;br /&gt;
                        $CustomField-&amp;amp;gt;Type eq &amp;#039;SelectMultiple&amp;#039; );&lt;br /&gt;
      $OUT .= $CustomFieldValue-&amp;amp;gt;Content . &amp;quot;\n&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    $OUT .= &amp;quot;\n&amp;quot; if ( $CustomField-&amp;amp;gt;Type eq &amp;#039;FreeformMultiple&amp;#039; or&lt;br /&gt;
                        $CustomField-&amp;amp;gt;Type eq &amp;#039;SelectMultiple&amp;#039; );&lt;br /&gt;
  }&lt;br /&gt;
  $OUT;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
This works for Ticket Level custom fields. This will not list Transaction Custom Fields.&lt;br /&gt;
&lt;br /&gt;
In order to access Transaction Custom fields e. g. in a Template, it is necessary to enable the [[TransactionBatch]] stage. If this is not enabled, a script might trigger a Template at a point in time when the custom field is not yet available because it had not been processed yet.&lt;br /&gt;
&lt;br /&gt;
The following worked for me (Debian, rt 3.4.1, to include a Transaction custom field in a template that is triggered by a scrip running on &amp;quot;[[TransactionBatch]]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 my $OwnCustomFieldValue;&lt;br /&gt;
 my $ViValue;&lt;br /&gt;
 my $TicketObj = $Ticket;&lt;br /&gt;
 my $OwnObjectCustomFields = $TicketObj-&amp;amp;gt;Transactions;&lt;br /&gt;
 &lt;br /&gt;
 $OwnContent = $Transaction;&lt;br /&gt;
 $OwnCustomFieldValue=$OwnContent-&amp;amp;gt;CustomFieldValues;&lt;br /&gt;
 &lt;br /&gt;
 while (my $SingleOwnCustomFieldValue = $OwnCustomFieldValue-&amp;amp;gt;Next)&lt;br /&gt;
 {&lt;br /&gt;
      $ViValue=$SingleOwnCustomFieldValue-&amp;amp;gt;Content;&lt;br /&gt;
      $RT::Logger-&amp;amp;gt;debug( &amp;quot;&amp;amp;gt;  CustomField: $ViValue  &amp;amp;lt;&amp;amp;lt;&amp;amp;lt;&amp;amp;lt;&amp;amp;lt;&amp;amp;lt;&amp;amp;lt;&amp;amp;lt; \n\n&amp;quot; );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
I assume that it is also possible to access custom-field name via [[CustomField]]-&amp;amp;gt;Name and the custom-field type via [[CustomField]]-&amp;amp;gt;Type.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>