How to store or fetch frequently searched data on a input search tool to an aggregate
Question
Application Type
Reactive

Hi Team,

I have to fetch and  store the searched text or data of the input search tool box to a table or aggregate in reactive web application. What should be the logic behind it and how will that work.

For better understanding, like on amazon or flipkart if any user searches "iphone" then the item searched and who searched it as well the ip address with searched time should be stored in an aggregate. So, how to fetch that searched data in an aggregate and later display it in form of table?

Hi,

1.  If I need to use this logic by creating table in other module and using it in another - You can take reference of that entity module in current module 

2. If search text box has assigned variable  - at the save time assign it to the entity's attribute and then use create and update

Kind Regards,


Hi,

On the search action use create and update of the entity in which you are storing the search data.

To createandUpdate action give the value of input field that you used to store.

Kind Regards,


Can you provide me any visual or oml of this solution?


Here i have attached the OML for your reference, You will get the logic in search screen and searched data in screen1.

Hope that helps,

Kind Regards,


SearchSample.oml

Hi Komal,

Thanks for sharing the oml. I understood the concept. But, If I search anything then why do i get the current searched item only, why not the previous one too? Means one user can search various items, so i must get those as well.

Hi Aditya,

Correct, whatever user want to search he'll click on search button right, when he hits the search button the searched record will added to the entity.

Do you want to show the search records some where?

or what's your exact doubt? 

Yes actually, i want all the searched record and need to fetch that in an aggregate. like u have taken name entity, if there is search item, ip address entity, search time and so on. I need to fetch that data also and store that in the aggregate

that is what i did, wait i'll upload whole thing


Hi,

Implement same thing and try to fetch the data in other screen and check what happens,

The oml file stratify the your requirement.

Kind Regards,


SearchSample.oml

Did you get it or still stuck at some where?

I am getting Foreign Module error while uploading this oml in my personal environment


Can you share the error ?

Instead of uploading this Oml in your environment, create same logic in your existing project.

Kind regards 

Yes coz its developed in another environment so try to implement same logic in your project and see its as per your requirement or not.

Hi Aditya,

you need an entity like this one to store your data:


Create an action Search to be called when the button to search is clicked:


To display the data just create a screen by dragging the entity Search to the Web Flow and it will create the screen automatically.

Thanks Jose,

can you please share this oml? 

I created as an example inside another project.

It is a simple process. You should try to create by yourself based on the examples because it's the best way to learn :)

Yes I am trying to do that on my one but got stuck so it would be helpful if i go through the oml and see where i went wrong. I am a fresher and new to this outsystems as well

I applied the logic, in search action whenever i call the create action I get an error as ORA-0001...violated. And if i fetch create or update action in it, then i don't get any error but, i get only the current searched item and the previous one gets deleted automatically.

Hi,

It's not deleted, it's get updated with latest one,

In my OML I have also used the create and update but it create all the time instead of updating. 

I am not getting why this error occurs in your project.

Share the screen shot of your Error and the logic in your action.

Or If you have achieved your requirement then post the solution here or marked this post as solved.


Actually I think the problem is with the aggregate. The entity id was on IS Autonumber= No, so that is why i was getting user constraints error. But now, If Is_Autonumber is on Yes while publishing I am getting a error as Database Upgrade Error. SO is therer any solution for this?

The issue is solved and I can mark as solved but I have a query. If I need to use this logic by creating table in other module and using it in another and if the search text box already has some assigned variable. how shall i do that?

Hi,

1.  If I need to use this logic by creating table in other module and using it in another - You can take reference of that entity module in current module 

2. If search text box has assigned variable  - at the save time assign it to the entity's attribute and then use create and update

Kind Regards,


I got ur logic. But the search text box has a variable assigned with some Structure data type and that table item is have column with text datatype. So, I am having issue in that case while assign it in logic flow as datatype error gets generated.

datatype mismatch error while assigning that variable to the aggregate value.

share screen shot with error and data type of  structure 

See aditya, the logic behind this is quite easy but  i guess you are making it difficult it with adding all other stuff.

If you want it with structure then it also it quite easy. add the structure of same entity and use same variable to search box and then create and update.

I am not getting why this is so complicated for you

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