[rt-users] Custom Fields and Templates

Andy Harrison ah30 at harrisonfamily.com
Tue Mar 2 12:49:09 EST 2004


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Tue, 02 Mar 2004 19:43:22 +0300, Ruslan U. Zakirov wrote
Subject: "Re: [rt-users] Custom Fields and Templates"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> REPLY TO LIST TOO.
> I'm not a BestPractical's support team member. :)

Oops, that pesky Reply All button...

> {
>     my $CustomFields = $Ticket->QueueObj->CustomFields();
>     while (my $CustomField = $CustomFields->Next()) {
>       my $CustomFieldValues=$Ticket->CustomFieldValues($CustomField->Id);
> 
>       if ($CustomFieldValues->Count) {
>         $OUT .= $CustomField->Name . ":\n";
>       } else {
>         next;
>       }
> 
>       while (my $CustomFieldValue = $CustomFieldValues->Next) {
>         $OUT .= "\t" . $CustomFieldValue->Content . "\n";
>       }
>     }
>     $OUT;
> }
> 
> What do you think about this??? :)
> 		Best regards. Ruslan.

Thanx a lot.  Works like a champ.  

Here's my slightly modified finished product:

{
  my $CustomFields = $Ticket->QueueObj->CustomFields();
  while (my $CustomField = $CustomFields->Next()) {
    my $CustomFieldValues=$Ticket->CustomFieldValues($CustomField->Id);
    $OUT .= $CustomField->Name;
    if ($CustomFieldValues->Count) {
      $OUT .= ":" . " " x (20 - length($CustomField->Name));
    } else {
      $OUT .= ":\n";
      next;
    }
    while (my $CustomFieldValue = $CustomFieldValues->Next) {
      $OUT .= $CustomFieldValue->Content . "\n";
    }
  }
  $OUT;
 }

The hardcoded 20 for the length isn't very stylish, but I didn't feel
like bothering doing it right. Future individuals who try this snippet
will want to make sure it doesn't bite you if you have long CF names.

-- 
Andy Harrison
(full headers for details)



More information about the rt-users mailing list