Work item sort order

Default sort order

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

For example when adding work items via a work item query, the sort order defined in the query will also be reflected in documents generated via Bravo Notes

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.

This is the recommended way of controlling the sort order of your work items in Bravo Notes.

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, e.g. the values v8,v9,v10 will be sorted like this:

v10
v8
v9

Using the sortMode attribute we can make the sorting aware of numbers in string values.

Example: Use natural sort order to sort version numbers

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

// will result in 
- 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}}

// results in 

- Item 123 (New)
- Item 321 (New) - Item 101 (Active) - Item 109 (Active) - Item 14 (Closed) - Item 918 (Closed)


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.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us