Edgewall Software

Changes between Version 11 and Version 12 of TracTicketsCustomFields


Ignore:
Timestamp:
Oct 31, 2005, 3:27:54 PM (18 years ago)
Author:
Christopher Lenz
Comment:

Add example for report involving a custom field (from TracIniReportCustomFieldSample)

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v11 v12  
    22Trac supports adding custom, user-defined fields to the ticket module. Using custom fields, you can add typed, site-specific properties to tickets.
    33
    4 '''Note: In Trac 0.8, this feature is still experimental.'''
    5 
    64== Configuration ==
    7 Configuring custom ticket fields is done in the TracIni config file.
    8 
    9 All field definitions should be under a section named '''{{{[ticket-custom]}}}''' in the ini-file.
     5Configuring custom ticket fields is done in the [wiki:TracIni trac.ini] file. All field definitions should be under a section named `[ticket-custom]`.
    106
    117The syntax of each field definition is:
     
    7470}}}
    7571
    76 === Notes ===
    77 Do not insert space characters between '{{{|}}}'-separated option values for ''radio'' and ''select'' fields.
    78  * ok: {{{FIELD_NAME.options = un|deux|trois}}}
    79  * invalid: {{{FIELD_NAME.options = un | deux | trois}}}
     72''Note: To make an entering an option for a `select` type field optional, specify a leading `|` in the `fieldname.options` option.''
     73
     74=== Reports Involving Custom Fields ===
     75
     76The SQL required for TracReports to include custom ticket fields is relatively hard to get right. You need a `JOIN` with the `ticket_custom` field for every custom field that should be involved.
     77
     78The following example includes a custom ticket field named `progress` in the report:
     79{{{
     80SELECT p.value AS __color__,
     81   id AS ticket, summary, component, version, milestone, severity,
     82   (CASE status WHEN 'assigned' THEN owner||' *' ELSE owner END) AS owner,
     83   time AS created,
     84   changetime AS _changetime, description AS _description,
     85   reporter AS _reporter,
     86  (CASE WHEN c.value = '0' THEN 'None' ELSE c.value END) AS progress
     87  FROM ticket t
     88     LEFT OUTER JOIN ticket_custom c ON (t.id = c.ticket AND c.name = 'progress')
     89     JOIN enum p ON p.name = t.priority AND p.type='priority'
     90  WHERE status IN ('new', 'assigned', 'reopened')
     91  ORDER BY p.value, milestone, severity, time
     92}}}
     93
     94Note in particular the `LEFT OUTER JOIN` statement here.
    8095
    8196----
    82 See also: TracTickets, TracIni, TracIniReportCustomFieldSample
     97See also: TracTickets, TracIni