Login to follow
EncodingSortForSQL

EncodingSortForSQL (ODC)

Stable version 1.2.0 (Compatible with ODC)
Uploaded on 12 November 2024 by Community Labs
EncodingSortForSQL

EncodingSortForSQL (ODC)

Documentation
1.2.0

Installation

To install EncodingSortForSQL and use it in your project, you just need to follow the steps below:

  1. Install the component from the OutSystems Forge.
  2. Add a dependency to the library called EncodingSortForSQL.
  3. Check BuildSafe_SortClause to sanitize dynamic sort orders.
  4. Additionally check TextToSortAttributes if you need to parse a string to SortAttributes to be sanitized with BuildSafe_SortClause.
  5. Click on “Add”.

Both server actions use the structure SortAttribute which should be checked automatically, otherwise check it manually.


Usage

There are two options to use the library:

As function call in an expression

If no manipulation of the sort criteria is desired, the server actions can be used directly as a function in an expression:

BuildSafe_SortClause( TextToSortAttributes(Text, Default) )

  • The first parameter Text is the dynamic sort string received from the UI table control.
  • The second parameter Default allows passing a fallback sort in case the first parameter is an empty string. This suppresses SQL errors due to an invalid sort clause.
  • Both parameters allow using multiple columns, separated by a comma (e.g. "LastName, FirstName").

As separate elements in a flow

Alternatively, both server actions can also be used as individual elements in a flow. This allows to access the list generated with TextToSortAttributes and manipulate the sort order before using BuildSafe_SortClause to generate the sanitized text to be used in the advanced SQL. This is useful to add or remove attributes or to force a special order, for example.