CustomField: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
 
(9 intermediate revisions by 3 users not shown)
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.
== Custom Field Types ==


RT supports the following CF types:
RT supports the following CF types:
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 ==
Line 23: Line 31:
==== First, create the Custom Field ====
==== First, create the Custom Field ====


* Login as one with admin/superuser rights
:# Login as one with admin/superuser rights
* Go to Configuration > [[CustomFields]]
:# Go to Admin -> CustomField -> Create
* Click on Create
:# Fill out the form appropriately and click Create
* Fill out the form appropriately and save changes
:# From the submenu, click on "Applies to" and check and save the desired options. '''Note:''' This step is not applicable with the Custom Field types, "Groups" or "Users".


==== Next, place the Custom Field where you want it ====
== Modify CustomField Value ==
 
* Go to Configuration > Global > [[CustomFields]]
* Choose where you want your [[CustomField]] to appear
* Select the [[CustomField]] you wish to apply and click 'Submit'
 
If you have installed RTFM you can also define CustomFields for [[RTFM]] Articles 848555157547


== Modify CustomField Value ==


=== RT 3.6 ===
[[File:Update-CF-Values.png|Updating custom field values on Tickets|thumb|500px]]


Use the bulk update option
There are a number of ways to update a custom field's value depending on the custom field type.


=== RT 3.4 ===
;Tickets
:* Click on the desired ticket, then click on Basics from the submenu or click directly on the Custom Field portlet tab, to bring you to the Modify Ticket page (see screenshot)
:* From the ticket, you can click on Jumbo in the submenu
:* You can also update the custom fields of multiple tickets at once, by running a search, then click on Bulk Update from the submenu


Try the script below based on [http://use.perl.org/~Robrt/journal/25746 this journal entry]. This example renames '[[TaskType]]' values that were 'Sales Call' to 'Prospect' in the 'Sales' queue.
; Assets
:* Click on the desired asset, then click on Basics from the submenu or click directly on the Custom Field portlet tab, to bring you to the Modify Asset page
:* You can also update the custom fields of multiple assets at once, by running a search from within Assets, then click on Bulk Update from the submenu


<nowiki>#!/home/perl/bin/perl
; Articles
use strict;
:* Click on the desired article, then click on Modify from the submenu to bring you to the Modify Article page
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-&gt;new($RT::SystemUser);
my $cf = RT::CustomField-&gt;new($RT::SystemUser);
my $q  = RT::Queue-&gt;new($RT::SystemUser);
$tx-&gt;FromSQL(qq[queue="$queue" and "cf.$queue.{$cf_name}" = '$old_value']);
$q-&gt;Load($queue);
$cf-&gt;LoadByNameAndQueue(Queue =&gt; $q-&gt;Id, Name =&gt; $cf_name);
unless( $cf-&gt;id ) {
  # queue 0 is special case and is a synonym for global queue
  $cf-&gt;LoadByNameAndQueue( Name =&gt; $cf_name, Queue =&gt; '0' );
}
unless( $cf-&gt;id ) {
  print "No field $cf_name in queue ". $q-&gt;Name;
  die "Could not load custom field";
}
my $i=0;
while (my $t = $tx-&gt;Next) {
  print "Processing record #" . ++$i . "\n";
  my $type = $t-&gt;FirstCustomFieldValue($cf_name);
  print "Old Type = $type\n";
  my ($ret, $msg) = $t-&gt;DeleteCustomFieldValue(
    Field =&gt; $cf-&gt;Id,
    Value =&gt; $type
  );
  die "Error deleting old value: $msg" unless $ret;
  $t-&gt;AddCustomFieldValue(
    Field =&gt; $cf-&gt;Id,
    Value =&gt; 'Prospect'
  );
  $type = $t-&gt;FirstCustomFieldValue($cf_name);
  print "New Type = $type\n";
}
</nowiki>


== Simple Search Custom Field Values ==
; Group
:* Click on the desired group from Admin -> Groups -> Select, this will bring you to the Basics page where you can update the custom field accordingly


[[SearchCustomField]]
; User
:* Click on the desired user from Admin -> Users -> Select, this will bring you to the Modify User page where you can update the custom field accordingly


== Custom Fields in Email Ticket Creation ==
== External Custom Fields ==
In addition to manually specifying the Custom Field values you can have an external data source for them. For this you need to write a perl module, put it in the proper directory and set the [[SiteConfig|RT_SiteConfig]]. For details see the [https://docs.bestpractical.com/rt/4.4.6/extending/external_custom_fields.html manual].


[[OnCreateCheckCF]]
[[Category:RT44]]

Latest revision as of 08:23, 24 July 2023

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.

Custom Field Types

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

  1. Login as one with admin/superuser rights
  2. Go to Admin -> CustomField -> Create
  3. Fill out the form appropriately and click Create
  4. From the submenu, click on "Applies to" and check and save the desired options. Note: This step is not applicable with the Custom Field types, "Groups" or "Users".

Modify CustomField Value

Updating custom field values on Tickets

There are a number of ways to update a custom field's value depending on the custom field type.

Tickets
  • Click on the desired ticket, then click on Basics from the submenu or click directly on the Custom Field portlet tab, to bring you to the Modify Ticket page (see screenshot)
  • From the ticket, you can click on Jumbo in the submenu
  • You can also update the custom fields of multiple tickets at once, by running a search, then click on Bulk Update from the submenu
Assets
  • Click on the desired asset, then click on Basics from the submenu or click directly on the Custom Field portlet tab, to bring you to the Modify Asset page
  • You can also update the custom fields of multiple assets at once, by running a search from within Assets, then click on Bulk Update from the submenu
Articles
  • Click on the desired article, then click on Modify from the submenu to bring you to the Modify Article page
Group
  • Click on the desired group from Admin -> Groups -> Select, this will bring you to the Basics page where you can update the custom field accordingly
User
  • Click on the desired user from Admin -> Users -> Select, this will bring you to the Modify User page where you can update the custom field accordingly

External Custom Fields

In addition to manually specifying the Custom Field values you can have an external data source for them. For this you need to write a perl module, put it in the proper directory and set the RT_SiteConfig. For details see the manual.