2 Replies Latest reply on Jan 16, 2013 1:49 PM by 635396

    Javascript alert


      I'm trying to get a javascript alert to pop up when the user enters a person's name that already exists in the persons table.

      I wrote a plsql function that returns the names of people already in the table (names that match the name the user entered) and I need to get the result of this function in a javascript alert.

      I don't want to use validations because I'd like the alert to appear immediately after the user updated the name field.

      I also want the message to be just a notification for the user and let the user decide if he wants to insert the same person multiple times.
      I tried to do this with dynamic action that executes plsql code but with no success.

      Any ideas on how to do this?

      Thanks, Adrian
        • 1. Re: Javascript alert
          Keith Malay
          Hi Adrian,

          You could accomplish this by calling a javascript function "on-change" of the text field. The javascript function would need to *1.*Get the existing usernames from an on-demand process, *2.*Check the user-entered name against the results of the on-demand process, *3.*Present a javascript dialogue box to confirm the action.

          With that being said, I would consider using built-in APEX functionality to simplify, such as Text Field with Autocomplete. Instead of the normal text field you're using now, you could switch it to type Text Field with Autocomplete and specify an LOV query, such as:

          select user_name
          from your_user_table
          order by 1

          As the user types, they can see a list of names that already match what they're typing. In my opinion, this would be a much more elegant way to solve the problem.

          Not to mention much less work, which we're all fans of :)

          Here's an example of the Text Field with Autocomplete in case you haven't used it.

          user = demo
          pass = demo

          Hope this helps.

          Keith Malay
          • 2. Re: Javascript alert
            Hello Keith,

            I'll use the elegant and easy approach :)