Home » Applications » Oracle Fusion Apps & E-Business Suite » Custom Security - How can I obtain the PERSON_ID of the current user
Custom Security - How can I obtain the PERSON_ID of the current user [message #149126] Wed, 30 November 2005 03:42 Go to next message
stubbsy
Messages: 6
Registered: November 2005
Junior Member
Hi

I have created a security profile in HRMS and I need to add some code to the "Custom Security" tab. In my code I need to identify the user currently logged in (so that I can find his supervisor).
I have included an extract of my code below. Towards the end of the code I have hard coded person_id = 70 (for testing).
I need to change the hard coded value so that it dynamically uses the person_id of the current user (who will also be an employee).

Can anyone tell me how to do this?

Thanks

Paul

(
select a3.supervisor_id
from per_all_assignments_f a3
where a3.effective_start_date <= sysdate
and a3.effective_end_date >= sysdate
and a3.person_id = 70
)
Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #149135 is a reply to message #149126] Wed, 30 November 2005 04:50 Go to previous messageGo to next message
anikdatta
Messages: 16
Registered: October 2005
Junior Member
Use fnd_profile.user_id, or username to get the current user name

try to user this one

select fnd_profile.value('USER_ID') from dual

[Updated on: Wed, 30 November 2005 05:01]

Report message to a moderator

Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #149136 is a reply to message #149135] Wed, 30 November 2005 05:07 Go to previous messageGo to next message
stubbsy
Messages: 6
Registered: November 2005
Junior Member

I have tried using fnd_profile without success but perhaps I am using it incorrectly, could you give me an example of how to use this in my code to return the person_id

Thanks

Paul
Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #149138 is a reply to message #149136] Wed, 30 November 2005 05:20 Go to previous messageGo to next message
stubbsy
Messages: 6
Registered: November 2005
Junior Member
Apologies, you did provide an example but for some reason I could only see the first line of your reply so I missed it.

You have solved my problem, thank you very much for your reply.

Best regards

Paul

Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #149148 is a reply to message #149138] Wed, 30 November 2005 06:19 Go to previous messageGo to next message
stubbsy
Messages: 6
Registered: November 2005
Junior Member
Hi Anik

I am not sure what happened when I tried your suggestion but this solution does not work after all, perhaps I did not commited my change.
So could I pick your brains once more?

I have substituted your line of code for my hard coded value as shown below:

(select a3.supervisor_id
from per_all_assignments_f a3
where a3.effective_end_date >= sysdate
and a3.effective_start_date <= sysdate
and a3.person_id = (select fnd_profile.value('USER_ID') from dual)
)

If I use this code my security profile does not work as required but if I substitute "select fnd_profile.value('USER_ID') from dual)" for the hard coded value of the PERSON_ID the code does work.

This suggets that I am not picking up the PERSON_ID. Have you any suggestions?

Bear in mind it is the PERSON_ID I am after, not the USER_ID which I believe is different.
The user should have a PERSON_ID because they are also an employee and the employee record is linked to the user.

Thanks for any help you can give and sorry for the confusion

Paul


Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #149220 is a reply to message #149148] Wed, 30 November 2005 10:48 Go to previous messageGo to next message
adragnes
Messages: 241
Registered: February 2005
Location: Oslo, Norway
Senior Member
The USER_ID and the PERSON_ID are indeed different. The USER_ID uniquely identifies an applications user. It is the primary key to the FND_USERS table in the APPLSYS schema.

Given the USER_ID, it is however possible to retrieve the PERSON_ID given the USER_ID. In the FND_USERS table there is a column EMPLOYEE_ID which contains the PERSON_ID of the application user in question.

I think it might also be possible to retrieve the PERSON_ID directly from a profile option or by using the FND_GLOBAL API. Check the block with profile options using Help>Examine to see if you can find the PERSON_ID or take a look at the functions in the FND_GLOBAL package.

If you are writing Forms code you should use the profile options to get values, if you are writing server-side code you should use FND_GLOBAL instead.

--
Aleksander Dragnes

[Updated on: Wed, 30 November 2005 10:49]

Report message to a moderator

Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #150074 is a reply to message #149220] Tue, 06 December 2005 02:50 Go to previous messageGo to next message
stubbsy
Messages: 6
Registered: November 2005
Junior Member
I think my problem may be that I am accessing HR via Self Service and perhaps Self Service cannot access the environment variables holding user_id, employee_id etc.

I am creating the security profile and attaching it to the "Manager Self Service" responsibility for the user, running Security List Maintenance and then logging into HR via Self Service as the user.

I know that the security profile is being used by self service because if I hard code the user_id it works but of course in my real code I need to dynamically obtain the user_id because it is different for each user.

I would appreciate any further thoughts that anyone may have.

Thanks
Paul
Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #150361 is a reply to message #150074] Wed, 07 December 2005 09:16 Go to previous messageGo to next message
adragnes
Messages: 241
Registered: February 2005
Location: Oslo, Norway
Senior Member
Paul,

Exactly what are you trying to achieve. Are you extending a self-service application using JDeveloper with Framework extensions? There must be APIs there available to get session information.

--
Aleksander Dragnes
Re: Custom Security - How can I obtain the PERSON_ID of the current user [message #150363 is a reply to message #150361] Wed, 07 December 2005 09:59 Go to previous message
stubbsy
Messages: 6
Registered: November 2005
Junior Member
Hi Aleksander

My problem is that I am using Self Service HR and I have set up supervisor security such that each employee has a supervisor assigned to them via the supervisor tab on the assignment screen.

Each employee is also a user.

when a user (an employee) connects to HR, all but the most junior employees, will be able to select the responsibility "Manager Self Service (1)" which allows them to see any employee below themselves in the supervisor chain.
This works as expected and I am happy with this.

However, with the responsibility "Manager Self Service (1)" you are also given the option of a pick list (known as My List). This allows you to search for other employees, add these employees to your "My List" and administer these employees.
This is useful if for example, a project manager goes on leave because it allows another project manager to administer his staff until he returns.

The problem is that when you search for employees to add to your "My List", no matter what your own position is in the supervisor chain, you can see every employee in the entire company including Senior Managers, Directors etc. and administer these employees. This as you can imagine, is undesirable for several reasons.

To get around this problem, I created a security profile. In the "Custom Security" tab of the profile, I have added a bit code to work out the supervisor of the current user and restrict him from viewing the records of any employee higher than himself in the supervisor chain.
For this to work, I need my code to know which employee is currently logged in so I that I can find his supeervisor and hence his own position in the supervisor chain and then restrict records accordingly.

This is my problem, I know that my code works because if I hard code a user_id and connect as that user, my code restricts records as required but of course in real life, I can't hard code the user_id, I need to find it dynamically and this is what I can't get to work.
I have tried various suggestions without success including:
fnd_profile.value('USER_ID')
:$PROFILES$.user_ID

I am beginning to think that Self Service does not have access to these variables but I am not sure and if Self Service cannot access these variables, are there other variables I can use instead?

I know there is a lot of information in this post and I appreciate your help.

Thanks

Paul






Previous Topic: How pa_tasks table is related with per_all_people_f table
Next Topic: Implementation of Oracle HRMS in 2months for Aurobindo Pharma Ltd.
Goto Forum:
  


Current Time: Fri May 10 14:37:40 CDT 2024