External custom fields - use of description value

Hello,

We are using a custom field in our RT environment with an external source
to obtain selectable values. Our code is based on the documentation here:
https://www.bestpractical.com/docs/rt/4.2.9/extending/external_custom_fields.html.
We are providing both the ‘name’ and ‘description’ in the returned result.
We are using the custom field in our tickets.

We wish to have the ‘description’ field provided by our external source
displayed in the select element on the ticket form and the ‘name’ field
stored in the database, however only the name field is being displayed.

Is it possible to show the description field in the select box and store
the name field in the database if it is selected? Or is this working as
intended?

Also, what is the purpose of providing a description field at all? I can
not find any other mention of this field in the documentation.

Appreciate any help or advice you could send my way.

Cheers,
Ben

Hi,

the select type custom fields sadly don’t use the description at all.
But if you switch the type for the custom field to “Enter one value with
autocompletion”, the autocomplete list displays “Name (Description)”.
Maybe this is an option for you.

ChrisAm 26.10.2014 um 20:08 schrieb Ben Kelly:

Hello,

We are using a custom field in our RT environment with an external
source to obtain selectable values. Our code is based on the
documentation
here: https://www.bestpractical.com/docs/rt/4.2.9/extending/external_custom_fields.html.
We are providing both the ‘name’ and ‘description’ in the returned
result. We are using the custom field in our tickets.

We wish to have the ‘description’ field provided by our external source
displayed in the select element on the ticket form and the ‘name’ field
stored in the database, however only the name field is being displayed.

Is it possible to show the description field in the select box and store
the name field in the database if it is selected? Or is this working as
intended?

Also, what is the purpose of providing a description field at all? I can
not find any other mention of this field in the documentation.

Appreciate any help or advice you could send my way.

Cheers,
Ben

Hello,
We are using a custom field in our RT environment with an external source
to obtain selectable values. Our code is based on the documentation
here: [1]https://www.bestpractical.com/docs/rt/4.2.9/extending/external_custom_fields.html.
We are providing both the ‘name’ and ‘description’ in the returned result.
We are using the custom field in our tickets.
We wish to have the ‘description’ field provided by our external source
displayed in the select element on the ticket form and the ‘name’ field
stored in the database, however only the name field is being displayed.
Is it possible to show the description field in the select box and store
the name field in the database if it is selected? Or is this working as
intended?

it’s working as intended, but if you have a bit of perl knowledge, you
should be able to quickly add the description in
share/html/Elements/EditCustomFieldSelect.

example:

  • <% $name %>

  • <% ($value->Description) ? $value->Description : $value->Name %>

if you wan’t to show the description on an already assigned field, you
have to add a “ContentDescription” method in
local/lib/RT/ObjectCustomFieldValue_Local.pm that will filter on the
current CF Name assigned to object and get Description from CF values.
Something like:

------ snip ------
package RT::ObjectCustomFieldValue;

use strict;
no warnings qw(redefine);

sub ContentDescription {
my $self = shift;
my $content = $self->Content;
if ( grep { $self->CustomFieldObj->Type eq $_ } qw( Select Combobox ) ) {
my $Values = $self->CustomFieldObj->Values;
$Values->Limit( FIELD => ‘Name’, VALUE => $content );
if ( $Values->Count && $Values->Count == 1 ) {
my $Value = $Values->First;
$content = ( $Value->Description ) ? $Value->Name.’ (’.$Value->Description.’)’ : $Value->Name;
}
}
return $content;
}

1;
------ snip ------

Then use this method mainly in share/html/Elements/ShowCustomFields.

  •    $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
    
  •    $m->out( $m->interp->apply_escapes( $value->ContentDescription, 'h' ) );
    

Be warned that if you deleted a value in the CF, matching objects will
not be able to find the matching Description.

Easter-eggs Spécialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com