[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.6-98-ga639b1f
Kevin Falcone
falcone at bestpractical.com
Wed Nov 25 16:19:21 EST 2009
The branch, 3.8-trunk has been updated
via a639b1fe0fa90d3a56fa996e64d5364112faf43a (commit)
from 2a8c78902cf35b3b1d9377f54cbc9c8e1bf1c747 (commit)
Summary of changes:
lib/RT/Record.pm | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
- Log -----------------------------------------------------------------
commit a639b1fe0fa90d3a56fa996e64d5364112faf43a
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Sun Nov 8 11:46:10 2009 -0500
Add CustomFieldValuesAsString method
If you are using a multiple value custom field, FirstCustomFieldValue
doesn't help because you actually want all the values. This is a simple
wrapper function to save you writing the map.
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 2a95b6a..b2e1e71 100755
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1829,6 +1829,28 @@ sub FirstCustomFieldValue {
return $first->Content;
}
+=head2 CustomFieldValuesAsString FIELD
+
+Return the content of the CustomField FIELD for this ticket.
+If this is a multi-value custom field, values will be joined with newlines.
+
+Takes a field id or name as the first argument
+
+Takes an optional Separator => "," second and third argument
+if you want to join the values using something other than a newline
+
+=cut
+
+sub CustomFieldValuesAsString {
+ my $self = shift;
+ my $field = shift;
+ my %args = @_;
+ my $separator = $args{Separator} || "\n";
+
+ my $values = $self->CustomFieldValues( $field );
+ return join ($separator, grep { defined $_ }
+ map { $_->Content } @{$values->ItemsArrayRef});
+}
# {{{ CustomFieldValues
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list