19 | | * order: Sort order placement. (Determines relative placement in forms with respect to other custom fields.) |
20 | | * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. (''since 0.11.3'') |
| 57 | * order: Sort order placement relative to other custom fields. |
| 58 | * max_size: Maximum allowed size in characters (//Since 1.3.2//). |
| 59 | * format: One of: |
| 60 | * `plain` for plain text |
| 61 | * `wiki` for [WikiFormatting wiki formatted] content |
| 62 | * `reference` to treat the content as a queryable value |
| 63 | * `list` to interpret the content as a list of queryable values, separated by whitespace |
| 64 | * ticketlink_query: Query for linkifying ticket values. |
| 65 | Not applicable for format `plain` and `wiki`. |
41 | | * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. (''since 0.11.3'') |
42 | | |
43 | | === Sample Config === |
44 | | {{{ |
| 88 | * max_size: Maximum allowed size in characters (//Since 1.3.2//). |
| 89 | * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. |
| 90 | * '''time''': Date and time picker. (//Since 1.1.1//) |
| 91 | * label: Descriptive label. |
| 92 | * value: Default date. |
| 93 | * order: Sort order placement. |
| 94 | * format: One of: |
| 95 | * `relative` for relative dates. |
| 96 | * `date` for absolute dates. |
| 97 | * `datetime` for absolute date and time values. |
| 98 | |
| 99 | If the `label` is not specified, it will be created by capitalizing the custom field name and replacing underscores with whitespaces. |
| 100 | |
| 101 | Macros will be expanded when rendering `textarea` fields with format `wiki`, but not when rendering `text` fields with format `wiki`. |
| 102 | |
| 103 | For applicable fields, the `ticketlink_query` option |
| 104 | overrides [[TracIni#query-ticketlink_query-option|"[query] ticketlink_query"]], and the format is the same as |
| 105 | that option. When the `ticketlink_query` option |
| 106 | is not specified, `[query]` `ticketlink_query` is used to |
| 107 | linkify the field. |
| 108 | |
| 109 | === Sample Configuration |
| 110 | |
| 111 | {{{#!ini |
74 | | }}} |
75 | | |
76 | | ''Note: To make entering an option for a `select` type field optional, specify a leading `|` in the `fieldname.options` option.'' |
77 | | |
78 | | === Reports Involving Custom Fields === |
| 141 | |
| 142 | test_seven = time |
| 143 | test_seven.label = A relative date |
| 144 | test_seven.format = relative |
| 145 | test_seven.value = now |
| 146 | |
| 147 | test_eight = time |
| 148 | test_eight.label = An absolute date |
| 149 | test_eight.format = date |
| 150 | test_eight.value = yesterday |
| 151 | |
| 152 | test_nine = time |
| 153 | test_nine.label = A date and time |
| 154 | test_nine.format = datetime |
| 155 | test_nine.value = in 2 hours |
| 156 | }}} |
| 157 | |
| 158 | '''Note''': To make a `select` type field optional, specify a leading `|` in `fieldname.options` (e.g. `test_five`). |
| 159 | |
| 160 | === Reports Involving Custom Fields |
91 | | '''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. |
92 | | |
93 | | 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. |
94 | | {{{ |
95 | | #!sql |
| 172 | '''Note''': This will only show tickets that have progress set in them. This 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. |
| 173 | |
| 174 | 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: |
| 175 | {{{#!sql |
112 | | === Updating the database === |
113 | | |
114 | | 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: |
115 | | |
116 | | {{{ |
117 | | #!sql |
118 | | INSERT INTO ticket_custom |
119 | | (ticket, name, value) |
120 | | SELECT |
121 | | id AS ticket, |
122 | | 'request_source' AS name, |
123 | | 'None' AS value |
124 | | FROM ticket |
125 | | WHERE id NOT IN ( |
126 | | SELECT ticket FROM ticket_custom |
127 | | ); |
128 | | }}} |
129 | | |
130 | | 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: |
131 | | |
132 | | {{{ |
133 | | #!sql |
134 | | INSERT INTO ticket_custom |
135 | | (ticket, name, value) |
136 | | SELECT |
137 | | id AS ticket, |
138 | | 'request_source' AS name, |
139 | | 'None' AS value |
140 | | FROM ticket |
141 | | WHERE id NOT IN ( |
142 | | SELECT ticket FROM ticket_custom WHERE name = 'request_source' |
143 | | ); |
144 | | }}} |
| 192 | Note that option names in trac.ini are case-insensitive, so even if your option name includes uppercase characters: |
| 193 | {{{#!ini |
| 194 | [ticket-custom] |
| 195 | Progress_Type = text |
| 196 | }}} |
| 197 | you must use '''lowercase''' in the SQL: `AND c.name = 'progress_type'`. |