Filter the records by username

Filter the records by username

  

Hi All,


I have a list of record which will capture the username while creating a new account, so i need to filter the records through username from SQL statement Not with the aggregate. 

Example: I need to have a checkbox called "mywork" next to the text filed and when i select the checkbox and click on search it has to filter the records by logged in username. 

Solution Required: If i logged in as "Vinod Kumar R" then it has to filter the second record from the below table.

User:

Table Records:

Attached is the OML file for your reference.

Regards,

Vinod

Hi vinod, what you need to do is a simple sql filter. You don't even need to use the username as you have access to the UserId of the currently logged in user.

Example:


Notice the GetUserId() function that returns the currently logged user

Afonso Aguas wrote:

Hi vinod, what you need to do is a simple sql filter. You don't even need to use the username as you have access to the UserId of the currently logged in user.

Example:


Notice the GetUserId() function that returns the currently logged user


Hi Afonso,


SQL Statement worked well, but how do i assign a variable to Checkbox which is boolean.


Regards,

Vinod

Hi Vinod,

Here IsBoolean is the variable and assigned to checkbox.


Thanks,

Rajat Agrawal

Did your problem solved or not?


Thanks,

Rajat Agrawal

Hi Rajat,


I have any idea about Boolean varialble, but i am not able to assign the SQL isfiterbyuser variable to checkbox. It would be great if you share me the sample OML file which will contacts checkbox filter that will filter the records by username through SQL..


Regards,

Vinod

Solution

Hi Vinod,

1. Create a Session variable of type Boolean, or a Local variable in the page of type boolean and bind it to the Checkbox. LEt's call this variable IsFilterByUSer

2. Select your SQL, in the LOGIC, and define the VALUE of the parameter IsFilterByUser to be the variable IsFilterByUser.

3. If, instead of an SQL you are using an AGGREGATE (you should use aggregates whenever possible), add a filter in the aggregate and do something like this:

IsFilterByUser = False
OR
YourEntityName.YourUserIdFieldBame = GetUserId()


That's it.


Solution

Eduardo Jauch wrote:

Hi Vinod,

1. Create a Session variable of type Boolean, or a Local variable in the page of type boolean and bind it to the Checkbox. LEt's call this variable IsFilterByUSer

2. Select your SQL, in the LOGIC, and define the VALUE of the parameter IsFilterByUser to be the variable IsFilterByUser.

3. If, instead of an SQL you are using an AGGREGATE (you should use aggregates whenever possible), add a filter in the aggregate and do something like this:

IsFilterByUser = False
OR
YourEntityName.YourUserIdFieldBame = GetUserId()


That's it.



Thanks Eduardo, I got it