Skip to main content
Answer

current user

  • October 30, 2020
  • 1 reply
  • 119 views

Forum|alt.badge.img+5

I want to filter records based on the user that is currently logged into the application.

This should be possible as there are a lot of prefilters for My Projects and such, but can't seem to find out how to do this.

So how do I know what the current user is? And how do I use this in prefilters and views?

Best answer by Mark Jongeling

Hi Roy,

In the project I work on we use the function dbo.tsf_user(). This will return the current user his login name. If you would save these login names inside an employee table for example, you can use this inside your application for a variety of things, such as filtering records.

More on it here: https://docs.thinkwisesoftware.com/docs/kb/username.html

You can then use it in code to retrieve the unique employee id to use in other areas inside your application. Example code:

select p.project_name
from project p
where exists (select 1
from employee e
where e.employee_id = p.project_leader_id
and e.login_name = dbo.tsf_user()
)

This would then retrieve all project names where the project leader is the logged in user. 

Hope this helps you out!

Kind regards,
Mark Jongeling

This topic has been closed for replies.

1 reply

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Administrator
  • Answer
  • October 30, 2020

Hi Roy,

In the project I work on we use the function dbo.tsf_user(). This will return the current user his login name. If you would save these login names inside an employee table for example, you can use this inside your application for a variety of things, such as filtering records.

More on it here: https://docs.thinkwisesoftware.com/docs/kb/username.html

You can then use it in code to retrieve the unique employee id to use in other areas inside your application. Example code:

select p.project_name
from project p
where exists (select 1
from employee e
where e.employee_id = p.project_leader_id
and e.login_name = dbo.tsf_user()
)

This would then retrieve all project names where the project leader is the logged in user. 

Hope this helps you out!

Kind regards,
Mark Jongeling