Templates

Work item sort order

Default sort order

By default, work items appear in the exported document in the same order they were added.

Controlling the sort order in your template

For each section of your template that outputs work items, you can define one or multiple fields by which your work items should be sorted.

Example: Order work items alphabetically by title

{{#workItems orderBy="Title"}}
- {{ field 'Title' }}
{{/workItems}}

If you wish to sort in descending order, there are two ways of achieving this. Both ways are shown below.

Example: Descending sort order

{{#workItems orderByDescending="Priority"}}
- {{ field 'Title' }}
{{/workItems}}
{{#workItems orderBy="Priority desc"}}
- {{ field 'Title' }}
{{/workItems}}

It is also possible to specify additional fields to sort by when work items have the same value for the first sort field.

Example: Ordering work items by priority and by title

{{#workItems orderBy="Priority,Title"}}
- {{ field 'Title' }}
{{/workItems}}

Descending sort order and multiple sort fields can also be combined by using the syntax below.

Example: Combining multiple sort fields and descending sort order

{{#workItems orderBy="Priority desc,Title"}}
- {{ field 'Title' }}
{{/workItems}}

Sorting version numbers and other string values including numbers

By default, sorting happens character by character, which sometimes results in unexpected outcomes.

For example we may want to sort version number values v8,v9,v10 and the outcome by default will look ike this:

v10
v8
v9

To sort version numbers and other string values including numbers, we can use the sortMode attribute.

Example: Use natural sort order to sort version numbers

{{#workItems orderBy="Version" sortMode="natural"}}
- {{ field 'Version' }}
{{/workItems}}

This will result in the expected sort order:

- v8
- v9
- v10

Use a custom defined sort order

Sometimes when using the orderBy argument, we need to pre-define a sort instead of the default alphabetical order.

Example: Sort by state using custom sort order

{{#workItems orderBy="State" sortOrder="New,Active,Closed"}}
- {{ field 'Title' }} ({{ field 'State' }})
{{/workItems}}

Sorting groups of work items

When grouping work items, you likely care about the order in which the groups are output in your template. All attributes to control the sort order mentioned above can also be used in the group helper. Use the special string $key to refer to the group field.

{{#group 'Category' orderBy="$key"}}
{{#eachGroup}}

## {{$key}}

{{#workItems}}
### {{ field 'Title' }}
{{/workItems}}

{{/eachGroup}}
{{/group}}

Manually changing the sort order in the Work items tab

In the Work items tab in Bravo Notes, you can manually reorder work items via drag & drop. Just drag a work item to the desired position within the table.

Any sort order specified in the template will take precedence over the manually changed sort order.

Previous
Parameters