Skip to content

Commit 3207dc7

Browse files
committed
Merge branch '6.0/document-ticketsql' into 6.0-trunk
2 parents f0c7b4f + 13f5877 commit 3207dc7

File tree

12 files changed

+5517
-284
lines changed

12 files changed

+5517
-284
lines changed

devel/docs/format_grammar.md

Lines changed: 2049 additions & 0 deletions
Large diffs are not rendered by default.

devel/docs/ticketsql_grammar.md

Lines changed: 1632 additions & 0 deletions
Large diffs are not rendered by default.

docs/query_builder.pod

Lines changed: 172 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -149,45 +149,10 @@ formats for different searches (see L</"Saved Searches">).
149149

150150
=head2 Advanced Output Formatting
151151

152-
There are some additional advanced features you can use to further customize
153-
the appearance and functionality of your search results. You can enable
154-
these by editing the underlying Format definitions directly. To see these
155-
definitions, click the Advanced tab in the Query Builder.
156-
157-
The Advanced page shows the full text of your query at the top, and has a
158-
Format box on the bottom, which shows the actual format definition for the
159-
columns you have selected. You can change these directly in the Format box
160-
to refine how columns are shown in search results. Here are some examples
161-
of changes you can make.
162-
163-
=over
164-
165-
=item Change the Column Title
166-
167-
The default column format for the ticket ID looks like:
168-
169-
'<a href="__WebPath__/Asset/Display.html?id=__id__">__id__</a>/TITLE:#',
170-
171-
If you want the column title to show "ID" rather than "#", you can change
172-
it to:
173-
174-
'<a href="__WebPath__/Asset/Display.html?id=__id__">__id__</a>/TITLE:ID',
175-
176-
=item Filter Link Types
177-
178-
The default format for links, like Depends On, looks like this:
179-
180-
'__DependsOn__',
181-
182-
A ticket can have links to other tickets, assets, or other things. If you
183-
want to filter the display to only show asset links, you can update the
184-
format like this:
185-
186-
'__DependsOn.{Asset}__',
187-
188-
If you set "Ticket" instead of "Asset", it will show only ticket links.
189-
190-
=back
152+
For additional formatting options beyond what the Display Columns interface
153+
provides, you can edit format strings directly on the Advanced tab. See
154+
L</"Format Strings"> in the Advanced section below for details on format
155+
syntax, modifiers, and examples.
191156

192157
=head1 Dynamic Filtering and Sorting
193158

@@ -671,6 +636,12 @@ search.
671636
If you need the username of the current user rather than the id, you
672637
can use "__CurrentUserName__".
673638

639+
The "__Inactive__" placeholder is the counterpart to "__Active__" and
640+
expands to all inactive statuses (resolved, rejected, deleted in the
641+
default lifecycle). This is useful for finding completed tickets:
642+
643+
Status = '__Inactive__' AND Queue = 'Support'
644+
674645
The value "__SelectedUser__" is similar and it defaults to the current
675646
user if run with a search by itself. However, if you create a dashboard,
676647
add the component "SavedSearchSelectUser", and also add your saved search,
@@ -688,6 +659,13 @@ case as a value for "id":
688659
That finds all tickets bookmarked by the current user. Bookmarks are
689660
added using the bookmark icon in the menu on each ticket.
690661

662+
For the Owner field, the special value "Nobody" represents unassigned
663+
tickets:
664+
665+
Owner = 'Nobody' AND Status = '__Active__'
666+
667+
This finds all active tickets that don't have an owner assigned yet.
668+
691669
These search terms can be used with additional search terms like any
692670
other search. So you could create a new saved search to show only your
693671
new or open bookmarked tickets like this:
@@ -732,6 +710,161 @@ To compare LargeContent instead:
732710

733711
=back
734712

713+
=head2 TicketSQL Reference
714+
715+
The query language behind the Query Builder is called TicketSQL. While most
716+
users can build searches using the graphical interface, understanding
717+
TicketSQL can be helpful for complex queries or when sharing searches.
718+
719+
=head3 Query Structure
720+
721+
TicketSQL queries combine conditions with AND and OR operators:
722+
723+
Queue = 'Support' AND Status = 'open'
724+
Status = 'new' OR Status = 'open'
725+
(Queue = 'General' OR Queue = 'Support') AND Status = '__Active__'
726+
727+
Use parentheses to control how conditions are evaluated.
728+
729+
=head3 Operators
730+
731+
TicketSQL supports several operators:
732+
733+
=over
734+
735+
=item Equality: C<=>, C<!=>
736+
737+
Status = 'open'
738+
Queue != 'Spam'
739+
740+
=item Comparison: C<E<lt>>, C<E<gt>>, C<E<lt>=>, C<E<gt>=>
741+
742+
Priority > 50
743+
Created < '2023-01-01'
744+
745+
=item String matching: C<LIKE>, C<NOT LIKE>
746+
747+
Subject LIKE 'server'
748+
Content LIKE 'error message'
749+
750+
=item NULL checks: C<IS NULL>, C<IS NOT NULL>
751+
752+
Due IS NOT NULL
753+
CF.{Category} IS NULL
754+
755+
=back
756+
757+
=head3 Common Patterns
758+
759+
Here are some useful query patterns:
760+
761+
# My active tickets
762+
Owner = '__CurrentUser__' AND Status = '__Active__'
763+
764+
# Unowned tickets
765+
Owner = 'Nobody' AND Status = '__Active__'
766+
767+
# Overdue tickets
768+
Due < 'today' AND Status = '__Active__'
769+
770+
# Tickets created this week
771+
Created > 'last Sunday'
772+
773+
# High priority bugs
774+
CF.{Category} = 'Bug' AND Priority > 80
775+
776+
# Tickets with dependencies
777+
DependsOn IS NOT NULL
778+
779+
For a complete list of searchable fields, see
780+
L<Ticket Metadata|docs/ticket_metadata.pod>.
781+
782+
=head2 Format Strings
783+
784+
The Format parameter controls which columns appear in search results and
785+
how they display. The Query Builder provides a graphical Display Columns
786+
interface, but you can also edit format strings directly on the Advanced page.
787+
788+
=head3 Basic Syntax
789+
790+
A format string is a comma-separated list of columns:
791+
792+
id, Subject, Status, Queue
793+
794+
To add a custom column header, use the C</TITLE:> modifier:
795+
796+
'__id__/TITLE:#', '__Subject__/TITLE:Subject', Status, QueueName
797+
798+
Field names are wrapped in double underscores when using modifiers.
799+
800+
=head3 Creating Links
801+
802+
To make ticket ID and Subject clickable:
803+
804+
'<a href="__WebPath__/Ticket/Display.html?id=__id__">__id__</a>/TITLE:#',
805+
'<a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a>/TITLE:Subject'
806+
807+
=head3 Date Display
808+
809+
Dates can be displayed as absolute values or relative times:
810+
811+
=over
812+
813+
=item C<Created> - Shows "2024-01-15 14:30:00"
814+
815+
=item C<CreatedRelative> - Shows "2 days ago"
816+
817+
=back
818+
819+
Relative dates are helpful for dashboards; absolute dates are better for
820+
reports.
821+
822+
=head3 Custom Fields
823+
824+
Include custom fields using:
825+
826+
'__CustomField.{Department}__/TITLE:Dept'
827+
'__CF.{Priority Level}__/TITLE:Priority'
828+
829+
=head3 Modifiers
830+
831+
Format columns support several modifiers:
832+
833+
=over
834+
835+
=item C</TITLE:text> - Column header
836+
837+
=item C</ALIGN:left|center|right> - Alignment
838+
839+
=item C</CLASS:name> - CSS class (Bootstrap 5 classes work)
840+
841+
=back
842+
843+
Example with alignment:
844+
845+
'__id__/TITLE:#/ALIGN:right'
846+
847+
=head3 Filtering Link Types
848+
849+
Link columns like DependsOn can show links to different object types.
850+
To filter to a specific type:
851+
852+
'__DependsOn.{Asset}__' # Show only asset links
853+
'__DependsOn.{Ticket}__' # Show only ticket links
854+
855+
=head3 Special Tokens
856+
857+
=over
858+
859+
=item C<NEWLINE> - Creates a two-row display
860+
861+
=item C<NBSP> - Adds an empty column
862+
863+
=back
864+
865+
For more complex formatting, the Display Columns interface in the Query
866+
Builder provides dropdowns for available fields and options.
867+
735868
=head1 Learn More
736869

737870
To use the query builder to build and save reports, see

0 commit comments

Comments
 (0)