Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dynamic Action to Execute PL/SQL which calls a JavaScript Alert - not working

jason02Jul 15 2014 — edited Jul 16 2014

Greetings,

I am stuck!  I'm using Apex Version 4.2.2.  I have a requirement that, when the user populates field1, I check the database to see if the value in field1 has already been used.  If it has been used, I need to inform the user but the user is allowed to reuse the value - ie., duplicates are allowed.  My thought is to use a dynamic action to check the value onchange which executes pl/sql to do the check (via a function in the database) and, if it returns true, use a javascript alert to inform my user that the value is in use.  They can then close the alert and change (or not change) the duplicate value

I have done the following:

1.  Wrote a function in PL/SQL in my utility package in the database - we'll call it  apps.my_utils.check_value_use(p_my_val in varchar2) return Boolean - this works.

2.  Created a Dynamic Action with the following properties for P1_FIELD1:

       Event: Change

       Selection Type: Item(s)

       Item(s): P1_FIELD1

       Condition: is not null

3.  The Dynamic Action has just one action - a True Action

      Action: Execute PL/SQL Code

      Page Items to Submit: P1_FIELD1

      PL/SQL Code:

BEGIN

  IF apps.my_utils.check_value_use(:P1_FIELD1) = TRUE THEN

    htp.p('<script type="text/javascript">');

    htp.p(' alert(''This value is in use'');

             ');

    htp.p('</script>');

  END IF;

END;

When I run the page and populate field1 with a value I know is in use, I get the following error:

     Error: parsererror - SyntaxError: JSON.parse: unexpected character

Please help.  I've already spent far too much time on this seemingly simple requirement.

Thanks,

J.

This post has been answered by xarg-Xrc on Jul 16 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2014
Added on Jul 15 2014
5 comments
8,670 views