[rt-users] Can values of Custom Field be based on Queue?

Christian Loos cloos at netcologne.de
Mon Oct 26 11:41:35 EDT 2015


Am 26.10.2015 um 15:18 schrieb Matt Zagrabelny:
> On Mon, Oct 26, 2015 at 2:56 AM, Chrilly Cheng <chrilde at gmail.com> wrote:
>> Hi All,
>>
>> I'm trying to find to way to get this requirement work.
>>
>> We have multiple queues in RT, like queueA, queueB, queueC. All queues are
>> using the same Custom Field that applied to them. One of those Custom Fields
>> is called Customer, which is using external values from a REST API. What we
>> want is in different queue, this Customer filed should shows different
>> drop-down list for user to select.
>>
>> Can this be done?
> 
> Kind of...
> 
> Have separate CFs each named Customer and apply each to their
> respective queue. Then populate those CFs with the values you'd like.
> 
> We do this with a CF named 'Problem Type'. We put the queue name in
> the Description field of the CF so we can get a sense of what queue
> the CF is applied to when viewing the CF details.
> 
> The CFs won't be global, but they'll each have the same name, so code
> that is queue specific will load the correct Customer CF and thus the
> correct values for the CF.
> 
> The other solutions for this problem involve more JS and AJAXy code.

If you use RT 4.2.10 or later this can easily be done (see [1]).

In you ExternalValues method within your RT::CustomFieldValues::???
package put this:

my $queue  = $self->CustomFieldObject->ContextObject->QueueObj;

to get a RT::Queue object.
You can then return different values based on the Queue id or name.
I would prefer to use the Queue id instead of the Name as the later one
can easily be changed in the WebUI.
If you just want the Queue Id you can put this instead of the above in
your method:

my $queue_id = $self->CustomFieldObject->ContextObject->Queue;

because $self->CustomFieldObject->ContextObject is actually a RT::Ticket
object.


Chris

[1] https://github.com/bestpractical/rt/commit/a84b429



More information about the rt-users mailing list