It is possible to create a search that ignores the uppercase, lowecase and accents?

Hi everyone,

I am building an reactive application and I need to filter a table that contains a lot of records in portuguese. In Portugal we are a lot of accents, so i need to filter the records ignoring the accents, and a plus, ignoring uppercase and lowercase. There any solution for this problem?

Hey Pedro,

to ignore upper and lower case, you can simply choose one of them and use the built-in function ToLower() or ToUpper() on your filter.

Regarding the accents, you have some forge components that can help you such as https://www.outsystems.com/forge/component-overview/9165/normalize-string


Hope this helps you!



Thanks for the help.

But in the accents problem, theres any kind of solution that not contains components of the forge? I don't know if i am able to use new components on the project that i am

Hi Pedro,

You can use like in your aggregates filter.

SearchKeyword = ""
 or 
SampleData.Name like "%" + SearchKeyword + "%"


Below is the sample URL. You can perform search without lower, uppercase or accents- 

https://personal-itafqtdv.outsystemscloud.com/TableSample/SampleData


Thanks

Vinod

Can you upload the oml file to see how do you search withou accents?

Please find the attached OML. Please check SampleData screen.

TableSample.oml

Hi @Pedro Ricarte ,

I think the easiest way is building a function that receives your string and returns your string without accents, then in your aggegate filters you do this:

SearchKeyword = ""
 or 
RemoveAccents(SampleData.Name) like "%" + SearchKeyword + "%"

And your removeAccents function would have a JS node that does this, where "yourInputStr" is the text input you pass to your function:

yourInputStr.normalize("NFD").replace(/[\u0300-\u036f]/g, "")

Let me know if this helped!
Cheers,
Paulo
mvp_badge
MVP

Hi Pedro,

I was under the impression that the Local Storage is case-insensitive, just like server-side storage? With regards to the accents, there's no easy way to handle this, other than add another column that contains the text without the accents (and before storing the record, have some conversion function turning "ã" into "a", "ç " into "c" etc.), and search on that column instead. This of course would double the amount of storage needed for that column.

Hi,

You did not mention if you need to filter your values on client or server side or if you are filtering in SQL or in application code? Creating a function to replace / normalize a unicode character range like @Paulo Ritto suggested above is one solution which should work in both cases and it can also be used with ListFilter system action.

In SQL (Sql Server), if the (usually external) database has a different collation than OutSystems recommended default, you can specify a query specific collation by using Advanced query:

SELECT * FROM {Cities}
WHERE [Name] COLLATE Latin1_general_CI_AI Like '%Sao%' COLLATE Latin1_general_CI_AI

More info about collation + possible values can be found from Microsoft documentation, but in short, collation specified in that example turns everything in to case (_CI) & accent (_AI) insensitive ASCII for comparison purposes.

This OutSystems default is also a useful thing to know when facing a reverse situation (like accent-sensitive surname search).

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.