Solved

How to get user ID that performs a transaction.

  • 28 June 2021
  • 3 replies
  • 794 views

Userlevel 5
Badge +8

It seems like this should be easy but I am getting strange results. I’ve created a custom LU with 3 custom fields:  a checkbox for the user to use,  a ‘checked by’ field to capture the User who clicks the checkbox along with the date they did it.

The ‘Checked by’ field is created as Field Type = Read Only

 

I am using this expression:

 

This does correctly capture the user who is logged on and checks the checkbox. The problem is after that data is entered, when I later log on (or anyone else is) to view that info, it picks up my ID and the current date. It is picking up the user who is logged on (which it is supposed to) but I don’t want that to change when anyone views it. 

The custom field is not updateable and not insertable (they are grayed out, even if I wanted to make it Insertable but not updateable. 

 

I am out of ideas. Anyone out there have any? 

Thanks

 

icon

Best answer by Charith Epitawatta 28 June 2021, 19:54

View original

This topic has been closed for comments

3 replies

Userlevel 7
Badge +31

Hi @KLAVALLEY,

You need to use a Persistent type field instead of Read Only because you need to save the value of checked by field for it to persist. With a Read Only field, it would just fetch the current logged in user every time. 

This is what you can do to achieve this.

  1. Create a Persistent custom field.
  2. In custom field wizard’s properties window, click on the link next to “Default value”.
  3. Tick “PL/SQL Expression” and enter the expression.
    IFSAPP.FND_SESSION_API.GET_FND_USER()

     

  4. Finish the setup with any other options as necessary.

Now create the page and when you create a new record, current user will be fetched to the field automatically and saved to the database when you save the record. 

However, still the user would be able to change the default value before saving the record. To prevent users from doing that, simply make the field Read Only by doing an RMB →  Properties → Read Only.

Logged in as Alain but the record is saved as IFSAPP.

 

Hope this answers your question!

Userlevel 5
Badge +8

Thanks for another quick and great response, Charith. This is exactly what I needed. Your great help enables me to provide additional functionality for our users. It is MUCH appreciated!!

Userlevel 7
Badge +31

Glad to be of help! :)