Sign Up

Hey, Dev!
Are you looking for a forum full of active developers to help you?
So if you want to:
āž”ļø Get answers for your development issues
āž”ļø Help others
āž”ļø Write an article
āž”ļø Get rewarded for your active participation
Then you are going to love this place.

Have an account? Sign In


Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

OrclQA.Com

OrclQA.Com Logo OrclQA.Com Logo
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Blog
  • New Questions
  • Tutorials
    • Oracle Apex
    • Python
  • Tags
  • Users
  • Badges & Points
  • About
Home/Questions/Q 3799
In Process
Greg
Greg

Greg

  • 6 Questions
  • 7 Answers
  • 0 Best Answers
  • 57 Points
View Profile
  • 0
GregProfessional
Asked: November 29, 20202020-11-29T12:14:02+05:30 2020-11-29T12:14:02+05:30

Multiple validations in dynamic action

  • 0

I have a button in my 20.2 apex application and I want it to only run PL/SQL code if two page items both have a value. If I was only checking one page item, I could create a dynamic action with true and false actions based on an ITEM IS NOT NULL condition. How do I extend this to validating 2 items, each with a separate error message.

apex
  • 5
  • 87
  • 0
  • 0
  • Share
    • Share on Facebook
    • Share on Twitter
Answer

    5 Answers

    1. afzal

      afzal

      • India
      • 0 Questions
      • 23 Answers
      • 0 Best Answers
      • 154 Points
      View Profile
      afzal Professional
      2020-11-30T11:47:16+05:30Added an answer on November 30, 2020 at 11:47 am

      suppose your item is p1_item1, p1_item2
      validation– PL/SQL Function Body Returning Error Text

      begin
      if :p1_item1 is null and :p1_item2 is null then
      return ‘both item should not empty’;
      elsif :p1_item1 is null and :p1_item2 is not null then
      return ‘p1_item1 should not empty’;
      elsif :p1_item2 is null and :p1_item1 is not null then
      return ‘p1_item2 should not empty’;
      end if;
      end;
      —replace error message as your requirement
      Always Execute===> yes

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
      • Greg

        Greg

        • 6 Questions
        • 7 Answers
        • 0 Best Answers
        • 57 Points
        View Profile
        Greg Professional
        2020-12-01T10:05:17+05:30Replied to answer on December 1, 2020 at 10:05 am
        This answer was edited.

        Looking around, I see that you mean to add a page-level validation which validates 2 items.

        I have 2 buttons. One button requires only one field to be filled. The other requires both fields. Would it not be better for each field to validate itself, with the validation code dependant on the button pressed? If so, how do I know which button was pressed?

        • 0
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
    2. afzal

      afzal

      • India
      • 0 Questions
      • 23 Answers
      • 0 Best Answers
      • 154 Points
      View Profile
      afzal Professional
      2020-12-01T10:19:43+05:30Added an answer on December 1, 2020 at 10:19 am

      create validationĀ  as show in below

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
      • Greg

        Greg

        • 6 Questions
        • 7 Answers
        • 0 Best Answers
        • 57 Points
        View Profile
        Greg Professional
        2020-12-01T16:51:07+05:30Replied to answer on December 1, 2020 at 4:51 pm
        This answer was edited.

        The image is too low-resolution to read properly, but I think I have worked out what you are saying. In the Processes tab, I can create a validation routine which is only applied when a specific button is pressed. I can therefore create a validation routine for each button.

        Thanks.

        • 0
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
        • Greg

          Greg

          • 6 Questions
          • 7 Answers
          • 0 Best Answers
          • 57 Points
          View Profile
          Greg Professional
          2020-12-04T05:40:21+05:30Replied to answer on December 4, 2020 at 5:40 am
          This answer was edited.

          I finally got around to trying this but it still did not work. I think the problem is I am not submitting the page, but issuing explicit PL/SQL code to update the database. I have now tried 2 other options posted by Vinnish (Oracle Apex Validation Without Submit Using JavaScript and Ajax Callback) but they did not provide joy either.

          The current situation (using Vinnish’s AJAX method) is that the buttons return an error message saying that it cannot insert the record with a null value for such and such column (standard ORACLE error message), THENĀ  it displays the user-friendly error message, even though the actions generate the user-friendly message before it tries to insert the record.

          The first action reads as follows:
          apex.server.process('validate_comment',
          {
          pageItems : '#P11_NEW_POST, #P11_SELECTED_NODE'
          }
          ,
          {
          dataType : 'text', success : function(data)
          {
          if(data != 'SUCCESS') apex.message.alert(data);
          }
          }
          )

          The second action performs the insert.

          How do I get the first action to abort on error?

          Postscript: I have made this work by changing the INSERT code so it only attempts an INSERT if the 2 items are not null. That way, I only get to see the user-friendly error message.

          Is there a neater way of doing this?

          • 1
          • Share
            Share
            • Share on Facebook
            • Share on Twitter

    You must login to add an answer.

    Forgot Password?

    Sidebar

    Ask Question
    Write a Post
    • Recent
    • Answers
    • Engr. SM Hasem

      How to insert item data with default IG in IG ...

      • 0 Answers
    • suriya

      how to download multiple view/table data in one excel

      • 1 Answer
    • Engr. SM Hasem

      How to add one column data to another column in ...

      • 11 Answers
    • Bheem

      What is best way to design school time table?

      • 0 Answers
    • Vinish
      Vinish added an answer Below is an example to download the CSV file using… January 25, 2021 at 12:54 pm
    • afzal
      afzal added an answer step 1--- report query like-- select EMPNO, ENAME, JOB, MGR,… January 25, 2021 at 10:14 am
    • Engr. SM Hasem
      Engr. SM Hasem added an answer Thank you so much sir. January 25, 2021 at 9:22 am
    • Vinish
      Vinish added an answer For all rows? It seems you want to compare the… January 25, 2021 at 6:19 am
    • Vinish
      Vinish added an answer Ok, then create a dynamic action on the bill month… January 25, 2021 at 6:17 am

    Recent Blog Posts

    • Vinish

      Pro*C - Connect to Oracle Database

    • Vinish

      Copy URL to Clipboard on Button Click Examples

    • Vinish

      Find When Your Mac Was Last Shutdown

    • Vinish

      Oracle SELECT Statement

    • Vinish

      Python Append List to List Example

    Explore

    • Home
    • Blog
    • New Questions
    • Tutorials
      • Oracle Apex
      • Python
    • Tags
    • Users
    • Badges & Points
    • About

    © 2020 OrclQA.Com. All Rights Reserved. Privacy Policy