33
Views
9
Comments
how can i capture a user search on a page?

Hello everyone! I'm trying to create a search log on a page with searchable input fields, the idea is that  user performs a search, Then an audit log entry should be created for that result, and that log will contain the following: 

  • User ID
  • Time stamp
  • Search Criteria (IE what fields were populated, i dont need to know what they populated them with, yet) 
  • Role of the user. 

I dont really know if i should create a new entity that would house these search results, but im a little unsure on how to write the search inputs to that table. 

2022-12-30 09-46-57
Deepika Patel

Hi,

According to what I understand, you want to create the audit log when user performs a search, if yes then its better to create new entity for audit log.

Regards,

UserImage.jpg
Md Mansur

Hi @Morgan Kemp 

I have Attached Olm for your requirement so go though below Oml:

Explain:

1. Create a table with Follwing Attribute

  • User ID
  • Time stamp
  • Search Criteria (IE what fields were populated, i dont need to know what they populated them with, yet) 
  • Role of the use

2. Search Button You can insert Data in log Table like this

   1. Frist Find Role

2.Called Crud Operation with following Prop

Thanks

Md Mansur

Search.oap
2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Morgan Kemp ,

If you set this up, I would say, make it a reusable feature that you can apply to any user action you like.  What you do depends on how you want to use it later.  

If it is purely for logging, You could just stringify all search data in a single json.  

If you want to manipulate specific data later, or have the option for very specific qeueries, or represent them in a specific way in your ui later, you could model it out into a little data model, with each search attribute as a separate key/value child related to a parent searchlog record.

If you really only ever want this for this single screen, then don't make it generic, and just have a log entity that holds the search fields as attributes.

Dorine

UserImage.jpg
Morgan Kemp

I see, the idea is that all of this data will be thrown into a generic database where it can be run / generated from SQL on an external DB. But my main concern is that the existing search action is vast, and im just not too sure about how to intergrade the capture of my log into a crud. 

2021-09-06 15-09-53
Dorine Boudry
 
MVP

What do you mean "the search action is vast" ? This is just about recording user choices and activity, right ? So just a set of filter values ?

Also, are you sure you want to develop this inside your OutSystems application ? Maybe you're better off using existing offerings for front end logging / monitoring 

UserImage.jpg
Morgan Kemp

The existing search function covers 2 separate environments, as some of the searchable inputs are used with oAPIs that talk to said environments, im subsequently having to reference them also within my CS module that the CRUD is taking place. Its sadly not my decision to develop this in anywhere outside of the codebase that houses the frontend modules that we use. 

It could be that im also overcomplicating this. Essentially all i need is to be able to show that a user on our backoffice system searched on X fields at Y time, and have those results write to a table that can be reported on via a SQL. 

entity created within the CS module

Server action that i plan to integrate into the frontend module. 

2021-09-06 15-09-53
Dorine Boudry
 
MVP

ok, and just to have an idea, how much and what type of search criteria are there ?

As it sounds like this is just for possibly auditing, I would make a structure holding all of them as input to that server action, and than just do a deserialize into json, and store that json in the entity, but don't know if that's feasable.  

If it is for more functional goals, like allowing your marketeers to analyse these data, than just a json string is maybe not convenient.

2024-02-20 19-14-17
Niranjan Kumar

Hi @Morgan Kemp,

As @Dorine Boudry mentioned, if the logging is going to be used for marketeers, then you can try storing the searchable inputs in JSON consists of key-value pairs and wherever the logging is utilized, they can break it down to any format if needed.

[{"FieldKeyName1": "OptedValue1"}, {"FieldKeyName2": "OptedValue2"} {"FieldKeyName3": "OptedValue3"} {"FieldKeyName4": "OptedValue4"}] and so on.

This will not only give you flexibility to store any number of inputs but also avoid you from custom structures.

- Niranjan

2024-10-12 12-11-20
Kerollos Adel
Champion

hallo @Morgan Kemp  , 

may saving roles and critical as xml or Json help you , i create example you will find it in attachment 


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