7 Replies Latest reply: Jan 23, 2013 4:03 AM by Bas de Klerk RSS

    user authentication

      I have developed a small application which consist of many workspaces,It's about patient registeration . what I am trying to do now is populating the variable in the username field which has been entered in the login page to specific fields in my own tables to make sure no one is choosing the wrong name and avoid mistakes.
      anyone can help me please?
        • 1. Re: user authentication
          Bas de Klerk
          Hi number 931509 ;)

          You can use the user in PL/SQL via :APP_USER
          To set an item value with the logged in username you can set the default value to PL/SQL expression and user :APP_USER as the expression.

          If this is not working tell us where/how you want to use it and also your APEX version and authentication method ( database/APEX account ?? ).

          • 2. Re: user authentication
            I am very new to this environment..
            first I am using Application Express
            now if you can guide me step by step where should I go to update the field that will be highly appreciated
            here is my table and I have created a page for it. what I am looking for exactly is to have the field USER ID filled automatically as you mentioned with the APP_USER once the form is opened and it should also be uneditable.

            Physician ID
            Package ID
            Room Status
            User ID

            I am sure you have gone through this everyday and it's very simple but I need the steps please.
            also the expression to be written.
            thank you again.
            • 3. Re: user authentication
              could you please help me with the expression I need to write in the default ?
              • 4. Re: user authentication
                Bas de Klerk

                the situation gets a little bit more complex nopw, since you want to show the value display only but also want to update the field in the database ( which is a contradiction for APEX ).

                So it would be easiest to do it one step at a time if you're not familiar with this.

                First step would be to set the database USER_ID field which is already on your form.

                Go to the form page in APEX which you want to edit and open the USER_ID page item.
                Go to the TAB Default ( for this item ) and set the field Default Value to
                And also set the field Default Value Type to
                PL/SQL Expression
                Now if you run the form to create a new record this field should be populated with the application user who is logged in.

                Next step would be to hide this field and create a new readonly field which is just to display the value on your form.
                So first set the USER_ID field to Hidden ( property Display as )
                Next create a new page item of type Display Only and during the creation of this item set the "Source type" to PL/SQL expression and again set the expression to :APP_USER

                Now you also have a read only field which shows this value.

                Good luck.
                • 5. Re: user authentication
                  Thank you very very much I will try it once I reach my work after 12 hours and I will let you know what happened with me :D
                  can't wait!!
                  • 6. Re: user authentication
                    Hi Bas
                    yes it's perfect but don't you think making this item as display only and set the default value to APP_USER is enough ?
                    no need to create new item.. please advise
                    • 7. Re: user authentication
                      Bas de Klerk
                      Since APEX does not update the display only fields in the database when you submit the page (that's probably why they are called "Display only" :) ) you have to create a work around.

                      The example I gave you is the method I usually use.

                      Another way would be to create a dynamic action which disables the item on "Page load"
                      Also create a dynamic action which enables the item again on "Before page submit", make sure this is not fired on page load ( this is the default when you create the DA ).

                      No when you load the page the item gets disabled ( read only ), and just before submit it get's enabled again. The downside is that when your application is slow you can see the item getting enabled and there might still be a gap for the user to change the field value, that's why I prefer the first method.