Difference between revisions of "CustomField"

From Request Tracker Wiki
Jump to navigation Jump to search
(<pre> </pre>)
m
Line 1: Line 1:
A '''Custom''''''Field''' (CF) is a user defined property, usually of a [[Ticket]].
A '''Custom Field''' (CF) is a user defined property that can be applied to various parts of RT.


Each custom field has a Name, Description and Type.
Each custom field has a Name, Description and Type.
Line 11: Line 11:
* Fill in one text area (of which you can edit the size: [[ChangeCustomFieldTextAreaSize]])
* Fill in one text area (of which you can edit the size: [[ChangeCustomFieldTextAreaSize]])
* Fill in one wikitext area
* Fill in one wikitext area
* Fill in multiple wikitext areas
* Upload one image
* Upload one image
* Upload multiple images
* Upload multiple images
* Upload one file
* Upload one file
* Upload multiple files
* Upload multiple files
* Combobox: Select or enter one value
* Enter one value with autocompletion
* Enter multiple values with autocompletion
* Select date
* Select datetime
* Enter one IP address
* Enter multiple IP addresses
* Enter one IP address range
* Enter multiple IP address ranges


You can define global CustomFields or specific to a [[Queue]] (see "CUSTOM FIELDS IN QUEUES" at [[ManualAdministration]]). They can apply to [[Ticket]], [[Group]], User or Ticket [[Transaction]]s.
You can define global CustomFields or specific to a [[Queue]] (see [[ManualAdministration#CUSTOM_FIELDS_IN_QUEUES|CUSTOM FIELDS IN QUEUES]]). They can apply to a [[Ticket]], [[Articles|Article]], Asset, [[Group]], [[User]] or Ticket [[Transaction]]s.


== How to set up a custom field in a nutshell ==
== How to set up a custom field in a nutshell ==

Revision as of 10:11, 29 March 2019

A Custom Field (CF) is a user defined property that can be applied to various parts of RT.

Each custom field has a Name, Description and Type.

RT supports the following CF types:

  • Select one value
  • Select multiple values
  • Enter one value
  • Enter multiple values
  • Fill in one text area (of which you can edit the size: ChangeCustomFieldTextAreaSize)
  • Fill in one wikitext area
  • Upload one image
  • Upload multiple images
  • Upload one file
  • Upload multiple files
  • Combobox: Select or enter one value
  • Enter one value with autocompletion
  • Enter multiple values with autocompletion
  • Select date
  • Select datetime
  • Enter one IP address
  • Enter multiple IP addresses
  • Enter one IP address range
  • Enter multiple IP address ranges

You can define global CustomFields or specific to a Queue (see CUSTOM FIELDS IN QUEUES). They can apply to a Ticket, Article, Asset, Group, User or Ticket Transactions.

How to set up a custom field in a nutshell

First, create the Custom Field

  • Login as one with admin/superuser rights
  • Go to Configuration > CustomFields
  • Click on Create
  • Fill out the form appropriately and save changes

Next, place the Custom Field where you want it

If you have installed RTFM you can also define CustomFields for RTFM Articles 848555157547

Modify CustomField Value

RT 3.6

Use the bulk update option

RT 3.4

Try the script below based on this journal entry. This example renames 'TaskType' values that were 'Sales Call' to 'Prospect' in the 'Sales' queue.

 #!/home/perl/bin/perl
 use strict;
 use warnings;
 use lib qw(../lib);
 use RT;
 use RT::Queues;
 use RT::Tickets;
 use Data::Dumper;
 
 # CONFIGURATION
 my $queue = 'Sales';
 my $cf_name = 'TaskType';
 my $old_value = 'Sales Call'; # NB: This must be a valid value for the CF
 my $new_value = 'Prospect';
 # END CONFIGURATION
 
 RT::LoadConfig();
 RT::Init();
 my $tx = RT::Tickets->new($RT::SystemUser);
 my $cf = RT::CustomField->new($RT::SystemUser);
 my $q  = RT::Queue->new($RT::SystemUser);
 $tx->FromSQL(qq[queue="$queue" and "cf.$queue.{$cf_name}" = '$old_value']);
 $q->Load($queue);
 $cf->LoadByNameAndQueue(Queue => $q->Id, Name => $cf_name);
 unless( $cf->id ) {
   # queue 0 is special case and is a synonym for global queue
   $cf->LoadByNameAndQueue( Name => $cf_name, Queue => '0' );
 }
 unless( $cf->id ) {
   print "No field $cf_name in queue ". $q->Name;
   die "Could not load custom field";
 }
 
 my $i=0;
 while (my $t = $tx->Next) {
   print "Processing record #" . ++$i . "\n";
   my $type = $t->FirstCustomFieldValue($cf_name);
   print "Old Type = $type\n";
   my ($ret, $msg) = $t->DeleteCustomFieldValue(
     Field => $cf->Id,
     Value => $type
   );
   die "Error deleting old value: $msg" unless $ret;
   $t->AddCustomFieldValue(
     Field => $cf->Id,
     Value => 'Prospect'
   );
   $type = $t->FirstCustomFieldValue($cf_name);
   print "New Type = $type\n";
 }
 

Simple Search Custom Field Values

SearchCustomField

Custom Fields in Email Ticket Creation

OnCreateCheckCF