Edgewall Software

Changes between Version 15 and Version 16 of TracTicketsCustomFields


Ignore:
Timestamp:
Oct 1, 2006, 11:34:47 PM (16 years ago)
Author:
sid@…
Comment:

Add more detail to using custom fields in reports

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v15 v16  
    7575=== Reports Involving Custom Fields ===
    7676
    77 The 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.
     77Custom ticket fields are stored in the `custom_ticket` 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`.
    7878
    79 The following example includes a custom ticket field named `progress` in the report:
     79{{{
     80#!sql
     81SELECT p.value AS __color__,
     82   id AS ticket, summary, owner, c.value AS progress
     83  FROM ticket t, enum p, custom_ticket c
     84  WHERE status IN ('assigned') AND t.id = c.ticket AND c.name = 'progress'
     85AND p.name = t.priority AND p.type = 'priority'
     86  ORDER BY p.value
     87}}}
     88'''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 this custom field defined for that ticket, and thus will never show up on this ticket query. If that's all you want, you're set.
     89
     90If you want to show all ticket entries (with progress and without), you need to use a `JOIN` for every custom field that is in the query.
    8091{{{
    8192#!sql