Make filter using function TextToInteger in the same Local Variable type Text.

Hello,

I'm trying to allow user can make a filter by typing text or number, being able to do a search for a certain film not just by title or plot, but by year also. But I dont´t know how can I make it.

It works when I use:

 Movie.Title like "%"+SearchText+"%" or Movie.PlotSummary like "%"+SearchText+"%"

It just works for number when I Add:

or Movie.Year = TextToInteger(SearchText)

Maybe it is just a logic problem but I need your help for understand what I'm making wrong.Seems it's always trying to transform everything to integer.

Thanks



Hi Andre you have some limitation when you try to convert data types, in your case you are trying to convert a text ("Year") to an integer to use the Movie.year, but in your example, you trying to convert a text "Raiders" to an integer and the conversion isn't possible.

You can check about the possible date conversion on this link:https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Data_Conversion

and here

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Data_Types/Available_Data_Types


Hope I could hep you


Solution

Hi, friend! 

Just apply IntegerToText() in the attribute you need to filter:

IntegerToText(Entity.IntegerAttribute) like "%" + session.variable + "%"


Best regards

Solution

Hi Andre,


Just remove TextToInteger from filter. It will work for you.




Regards,

Rajat

Carlos Lessa wrote:

Hi Andre you have some limitation when you try to convert data types, in your case you are trying to convert a text ("Year") to an integer to use the Movie.year, but in your example, you trying to convert a text "Raiders" to an integer and the conversion isn't possible.

You can check about the possible date conversion on this link:https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Data_Conversion

and here

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Data_Types/Available_Data_Types


Hope I could hep you



Hi my friend, you're right. Thank You so much! I will check the links! I'm feel grateful for your help.

Lenon Manhães wrote:

Hi, friend! 

Just apply IntegerToText() in the attribute you need to filter:

IntegerToText(Entity.IntegerAttribute) like "%" + session.variable + "%"


Best regards


Hi Lenon,

Thanks for your very smart solution. I like your point of view about my problem.
I did as you recommend and it worked correctly.

Thank you for taking the time to help me.


Below, how it got.

Movie.Title like "%"+SearchText+"%" or Movie.PlotSummary like "%"+SearchText+"%" or IntegerToText(Movie.Year) like "%" + SearchText + "%"

Hi, friend!

I'm glad to help you.


Best regards


André Andrade de Paula wrote:

Lenon Manhães wrote:

Hi, friend! 

Just apply IntegerToText() in the attribute you need to filter:

IntegerToText(Entity.IntegerAttribute) like "%" + session.variable + "%"


Best regards


Hi Lenon,

Thanks for your very smart solution. I like your point of view about my problem.
I did as you recommend and it worked correctly.

Thank you for taking the time to help me.


Below, how it got.

Movie.Title like "%"+SearchText+"%" or Movie.PlotSummary like "%"+SearchText+"%" or IntegerToText(Movie.Year) like "%" + SearchText + "%"



Rajat Agrawal wrote:

Hi Andre,


Just remove TextToInteger from filter. It will work for you.




Regards,

Rajat

Thanks Rajat!

I am very grateful for your willingness and time to help me. I used Lenon's recommendations and it worked. I converted the "Year Attribute"  that is Integer to "text" and then I was able to use "like" normally.

Best Regards