Custom Ticket Fields

Trac supports adding custom, user-defined fields to the ticket module. Using custom fields, you can add typed, site-specific properties to tickets.

Configuration

Configuring custom ticket fields is done in the trac.ini file. All field definitions should be under a section named [ticket-custom].

The syntax of each field definition is:

 FIELD_NAME = TYPE
 (FIELD_NAME.OPTION = VALUE)
 ...

The example below should help to explain the syntax.

Available Field Types and Options

  • text: A simple (one line) text field.
    • label: Descriptive label.
    • value: Default value.
    • order: Sort order placement. (Determines relative placement in forms with respect to other custom fields.)
  • checkbox: A boolean value check box.
    • label: Descriptive label.
    • value: Default value (0 or 1).
    • order: Sort order placement.
  • select: Drop-down select box. Uses a list of values.
    • label: Descriptive label.
    • options: List of values, separated by | (vertical pipe).
    • value: Default value (one of the values from options).
    • order: Sort order placement.
  • radio: Radio buttons. Essentially the same as select.
    • label: Descriptive label.
    • options: List of values, separated by | (vertical pipe).
    • value: Default value (one of the values from options).
    • order: Sort order placement.
  • textarea: Multi-line text area.
    • label: Descriptive label.
    • value: Default text.
    • cols: Width in columns.
    • rows: Height in lines.
    • order: Sort order placement.

Sample Config

[ticket-custom]

test_one = text
test_one.label = Just a text box

test_two = text
test_two.label = Another text-box
test_two.value = Just a default value

test_three = checkbox
test_three.label = Some checkbox
test_three.value = 1

test_four = select
test_four.label = My selectbox
test_four.options = one|two|third option|four
test_four.value = two

test_five = radio
test_five.label = Radio buttons are fun
test_five.options = uno|dos|tres|cuatro|cinco
test_five.value = dos

test_six = textarea
test_six.label = This is a large textarea
test_six.value = Default text
test_six.cols = 60
test_six.rows = 30

Note: To make entering an option for a select type field optional, specify a leading | in the fieldname.options option.

Reports Involving Custom Fields

Custom ticket fields are stored in the ticket_custom table, not in the ticket table. So to display the values from custom fields in a report, you will need a join on the 2 tables. Let's use an example with a custom ticket field called progress.

SELECT p.value AS __color__,
   id AS ticket, summary, owner, c.value AS progress
  FROM ticket t, enum p, ticket_custom c
  WHERE status IN ('assigned') AND t.id = c.ticket AND c.name = 'progress'
AND p.name = t.priority AND p.type = 'priority'
  ORDER BY p.value

Note that this will only show tickets that have progress set in them, which is not the same as showing all tickets. If you created this custom ticket field after you have already created some tickets, they will not have that field defined, and thus they will never show up on this ticket query. If you go back and modify those tickets, the field will be defined, and they will appear in the query. If that's all you want, you're set.

However, if you want to show all ticket entries (with progress defined and without), you need to use a JOIN for every custom field that is in the query.

SELECT p.value AS __color__,
   id AS ticket, summary, component, version, milestone, severity,
   (CASE status WHEN 'assigned' THEN owner||' *' ELSE owner END) AS owner,
   time AS created,
   changetime AS _changetime, description AS _description,
   reporter AS _reporter,
  (CASE WHEN c.value = '0' THEN 'None' ELSE c.value END) AS progress
  FROM ticket t
     LEFT OUTER JOIN ticket_custom c ON (t.id = c.ticket AND c.name = 'progress')
     JOIN enum p ON p.name = t.priority AND p.type='priority'
  WHERE status IN ('new', 'assigned', 'reopened')
  ORDER BY p.value, milestone, severity, time

Note in particular the LEFT OUTER JOIN statement here.

Updating the database

As noted above, any tickets created before a custom field has been defined will not have a value for that field. Here's a bit of SQL (tested with SQLite) that you can run directly on the Trac database to set an initial value for custom ticket fields. Inserts the default value of 'None' into a custom field called 'request_source' for all tickets that have no existing value:

INSERT INTO ticket_custom
   (ticket, name, value)
   SELECT 
      id AS ticket,
      'request_source' AS name,
      'None' AS value
   FROM ticket 
   WHERE id NOT IN (
      SELECT ticket FROM ticket_custom
   );

If you added multiple custom fields at different points in time, you should be more specific in the subquery on table ticket by adding the exact custom field name to the query:

INSERT INTO ticket_custom
   (ticket, name, value)
   SELECT 
      id AS ticket,
      'request_source' AS name,
      'None' AS value
   FROM ticket 
   WHERE id NOT IN (
      SELECT ticket FROM ticket_custom WHERE name = 'request_source'
   );

See also: TracTickets, TracIni Most tough men eat nails for breakfast. chuck Norris does all of his grocery shopping at Home Depot.  http://www.mangaitalia.it/invision/index.php?showuser=29503

 buy Cialis west coast

 viagra levitra cialis  viagra generico prezzi  http://community.icontact.com/users/buy-tramadol  http://forum.desktopreview.com/member.php?u=145579  http://www.folkd.com/user/buyfioricetonline  http://codebetter.com/members/BuyCheapCialis/default.aspx sgcpBRU  ordinazioni viagra  fioricet where to order  cheap Cialis and Cialis 3cpkwb5  purchase tramadol

Gumperson's Law:

The probability of a given event occurring is inversely proportional to its desirability.

 http://blogs.devleap.com/members/Compra_2D00_Viagra.aspx

 buy cialis uk

 farmacia cialis  vendita viagra di marca  http://www.folkd.com/user/tramadolonline  http://codebetter.com/members/BuyCheapCialis/default.aspx  http://www.folkd.com/user/buyfioricetonline  http://us.lexusownersclub.com/forums/index.php?showuser=95591 hVHdPcB  ordinare viagra e cialis  buy cheap fioricet  pharmaceuticals Cialis taMiwFd  tramadol online order

Pauca sed matura.

[Few but excellent.]

-- Gauss

 http://www.popolodellarete.it/member.php?u=21746

 Buy Cialis -> Order Cheap Cialis Online! Free Prescription!

 ordine cialis per impotenza  ordinazioni viagra generico  comprare propecia online  http://compraviagraitalia.com/it/item/generic_propecia.html  http://www.maclife.com/user/buy_tramadol_0  http://wss-id.org/members/buycialis.aspx  http://www.sharepointblogs.com/members/buyfioricet/default.aspx  http://www.sharepointblogs.com/members/buycialis/default.aspx LU1UVX0  viagra di marca e cialis  fioricet uk  buy Cialis generic A7r6MLc  buy tramadol

To err is human, but I can REALLY foul things up.

 Cialis order  order viagra  http://www.maclife.com/user/buy_cialis_com  http://buycialis.cc/en/item/viagra.html  buy generic levitra  tramadol medication IEuGLrv  http://buycialis.cc/en/item/levitra.html  http://www.dogomania.com/forum/showthread.php?p=276144  buy fioricet prescription online  acquistare viagra siguro  http://www.aboutus.org/HeadacheTreatment.net  http://forum.ilmeteo.it/blog-ItaliaOnline?Compra-Viagra I came, I saw, I deleted all your files.  http://compraviagra.blog.espresso.repubblica.it/compra_viagra_e_cialis/

 buy cialis drugs

 come comprare cialis generico  viagra controindicazioni  propecia  http://www.tomshw.it/forum/members/compra-propecia.html  http://www.jayde.com/15219715-relievepain.html  http://members.ebay.com/ws/eBayISAPI.dll?ViewUserPage&userid=cialis-levitra  http://www.aboutus.org/HeadacheTreatment.net  http://www.hotfrog.in/Companies/Buy-Cialis-Online gEEufmg  ordina viagra on line  buy fioricet  cialis rx Ews3XVJ  relieve pain

Ours is a world of nuclear giants and ethical infants.

-- General Omar N. Bradley

 buy cialis canada  order viagra  http://www.aboutus.org/BuyCialis.cc  http://buyviagraonline.gather.com/  levitra online  order cheap tramadol online 7lsrVjR  http://buycialisonline.tv/product.php?prod=levitra  http://www.kaneva.com/channel/tramadol.people  brand fioricet fioricet  ordinare viagra e cialis  http://www.folkd.com/user/buyfioricetonline  http://www.warrock.it/forum/index.php?showuser=59718?Viagra-Cialis-Levitra The most hopelessly stupid man is he who is not aware that he is wise.  http://www.popolodellarete.it/member.php?u=21746

 side effects of Cialis

 dove comprare cialis generico  vendita viagra di marca  acquisto propecia  http://www.tomshw.it/forum/members/compra-propecia.html  http://www.dogomania.com/forum/showthread.php?p=276144  http://buycialis.reciter.com/  http://www.jayde.com/15220245-headachetreatment.html  http://us.cyworld.com/buybrandcialis/ 0anQgpK  viagra ordinare  cheap brand fioricet  order discount Cialis vjpeA6A  tramadol usa

Inheritance taxes are getting so out of line, that the deceased family

often doesn't have a legacy to stand on.  http://lnx.spmg.it/moodle/user/view.php?id=470&course=1&viagra-cialis

 buy cialis pills

 cialis di marca  viagra generico prezzi  comprare propecia online  http://compraviagraitalia.com/it/item/generic_propecia.html  http://www.kaneva.com/channel/tramadol.people  http://www.maclife.com/user/buy_cialis_com  http://www.xomreviews.com/headachetreatment.net  http://www.hotfrog.in/Companies/Buy-Cialis-Online RdG4hrl  acquistare viagra  fioricet uk  order cialis online UQeUbBo  tramadol free shipping

Q: What's the difference between an Irish wedding and an Irish wake?

A: One less drunk.  http://www.redhotchilipeppers.it/public/forum/index.php?/user/7012-viagra-e-cialis/

 order Cialis

 vendita cialis online  viagra generico  acquisto propecia  http://compracialis.it/it/item/generic_propecia.html  http://buycialisonline.tv/product.php?prod=ultram  http://community.tasteofhome.com/members/BuyCialis/default.aspx  http://www.headachetreatment.net/  http://buycialisonline.tv/product.php?prod=cialis ZFZsYXi  compra il levitra  fioricet net  Cialis Cialis prescription SNxAvSs  how to buy tramadol