How to Change the Entity Order

Options
Center of Excellence
edited April 2023 in How-To Guides

1.   Abstract    

An Entity sort is a parameter set when you create the Entity, which can be updated during the development phase. It may be necessary to evaluate the addition of new members or re-evaluate the order of the elements. In this case, it’s suggested to use a dynamic sorting mechanism based on a Cube and, in other cases, to use the native custom-sort function of the Entities.

2.   Context

You may want to change an Entity sort after a solution has been developed or apply a specific sort that can’t be achieved using standard methods (sort by None, Code, or Desc). Here’s how to easily change the sorting without impacting the solution.

3.   Content

3.1 Identifying the problem

Board offers different methods to sort Entity members. These methods fall into two different areas (which are also outlined in the Board Manual):

  • Entity definition: it’s possible to define a default sorting at the Entity level. This sorting is applied every time the Entity is shown or used (selector, pager, dataview, charts). It is a one-time setting, and it affects the whole model. In this case, we must define the ‘sort by’ option, selecting one of the four available options:

    • None: displays Entity members in the order that they were created
    • Code: sorts Entity members according to the code field, in ascending or alphabetical order
    • Desc: sorts Entity members according to the description field, in ascending or alphabetical order
    • Custom: applies a custom sort to Entity
  • Layout sort is a sorting applied at the layout level. This means that it is limited to only the layout where it’s been defined.

Please refer to the Board Manual for additional information.

There are some points to have in mind while addressing Entity sorting:

  • About the Entity itself:

    • What type of Entity needs a different sorting?  
    • Is it a stand-alone, or is it included in a tree?
    • Is it manually created or loaded with DR?
    • What is the frequency of Entity updates?  
  • About the required sorting:

    • How often will the sorting require an update?
    • Will end users ever need to change the sorting manually?
    • What is the required flexibility in changing the sorting?
    • Is the requirement to have a new default sorting for all Screens, tools, and interfaces?
    • Is the sorting only needed in specific Screens or layouts? Should the sorting be able to be different in different Screens or layouts?

3.2 Possible solutions

There are two different solutions to sorting issues:

  • Using dedicated sorting Cubes
  • Using the “custom sort” option

3.2.1   Sorting Cubes

Using sorting Cubes is the best solution when the requirement is to have the flexibility to apply different sorting rules display on different screens.

It will require you to create specific sorting Cube/s, structured by the Entity subject, to sorting and at least one technical Entity to identify the Screen or the layout. The requirement drives the definition of the granularity of this technical Entity.  

Sorting Cube/s must be added in all the required layouts and used to sort rows or columns. Remember to apply the correct selection (Screen selection or layout selection) on the technical Entity/ies. 

Figure 1. Apply layout sort

Like any other Cube, the sorting Cube can be populated manually by users or with a data reader or dataflow.

This approach is the most flexible but has one limitation: if the layout has two Entities set by row or by column, the sorting condition will consider only the most nested Entity.

The example below shows one example: the sort order is kept on the Entity named country, but it does not change the order of the parent Entity.

Figure 2. Example of sorting Cube having one or more Entities by row

3.2.2   Custom Sort

Custom Sort is one of the options of the ‘Entity Sort By’ parameter.

This is an excellent solution if you want a default sorting used in all the user interfaces. The custom sort can be applied to all the Entities in the hierarchy, so it’s possible to have the desired sorting even if more than one Entity is used in layout rows.

The custom sort of Entity members can be defined manually by an administrator or by using a specific data reader.

Here are a few quick suggestions:

  • If the Entity is manually created and manually managed, a custom sort can also be manually managed
  • If the Entity is loaded with a data reader, the best practice is also to manage the custom sort by the data reader
  • If the Entity is part of a hierarchy, you should also consider applying a coherent sort on parent entities, also

In addition, you may want to allow users to define the custom sort manually. In this case, it’s possible to define a data entry Screen where the user manually inputs the desired sort as a number. This will make it easy to export a layout sorted by this data and use the extraction as a source of the data reader. This step can also include parent Entities, so the order is coherent throughout the hierarchy.

It’s essential to watch the behavior of the custom sort defined with the data reader: if the source doesn’t contain all elements, it will cause elements that are contained in the source to be ordered from 1 to n (as they are listed in the source), but all others will be ordered from position n+1 to the end, based on their own index.