3 Replies Latest reply on Sep 13, 2017 12:58 PM by Joe R

    Help Creating A Conditional Success Message 5.1

    Joe R

      Version: 5.1.1.00.08

       

      Hello,

       

      I have a classic report that shows files that have been associated to questions. These files can be images, mp4, and zip.

       

      The application allows for the creation of questions and these files are used as supplemental information to the question asked.

      Something like "As you can see in the image what would you do to treat this condition?"

       

      So as the question is being developed the writer can choose a file to be associated to the question.

      That's what this classic report shows. It show what files are associated to the question.

       

      There are times when the same file can be associated to a different question. That information is captured when the file is associated.

       

      My issue is that the users want a message displayed when they remove a file that has been associated to the question, maybe because they decided they don't want that file.

      When they remove the file the message needs display what other questions that file has been associated with but if there's no other question that has that

      file associated then the message should just be that it was removed.

       

      I have a link on the row that is used to remove the row with the file they want to remove. When the link is clicked I'm setting a hidden page item with the ID and the page submits.

      I have an After Header process, conditional on the hidden item that does this work. I'm populating another hidden page item with the question numbers (called Case Numbers) to be displayed.

       

      Can someone help me with how to display 2 different success messages?

       

      This is the code to do this work for reference:

      DECLARE
          --The Asset is on another Part get the Case Number
          CURSOR get_case_id_cur (p_file_index IN NUMBER) IS
              SELECT c.case_number
              FROM  ib_parts_assets_x pax
              JOIN ib_case_parts cp ON pax.case_part_id = cp.case_part_id
              JOIN ib_cases c ON cp.case_id = c.case_id
              WHERE  pax.file_index = p_file_index AND
                     c.case_id != :P35_CASE_ID;

          v_asset_exists      NUMBER;
          v_iteration         NUMBER := 0;

       

      BEGIN
          --Determine if the Asset is on another Part
          SELECT COUNT (*)
          INTO v_asset_exists
          FROM  ib_parts_assets_x pax
          JOIN ib_case_parts cp ON pax.case_part_id = cp.case_part_id
          JOIN ib_cases c ON cp.case_id = c.case_id
          WHERE  pax.file_index = :P35_FILE_INDEX_DEL AND
                 c.case_id != :P35_CASE_ID;

       

          --If there are Assets get the Case numbers that
          --  are associated to the Asset being removed
          IF (v_asset_exists > 0) THEN
              FOR get_case_id_rec IN get_case_id_cur(:P35_FILE_INDEX_DEL)
              LOOP
                  v_iteration := v_iteration + 1;

                  IF (v_iteration = 1) THEN
                      :P35_CASE_ENEMY := get_case_id_rec.case_number;
                  ELSE
                      :P35_CASE_ENEMY := :P35_CASE_ENEMY || ', ' || get_case_id_rec.case_number;
                  END IF;
              END LOOP;
          END IF;

       

          --Delete the Asset
          IF (:P35_FILE_INDEX_DEL IS NOT NULL) THEN
              DELETE FROM ib_parts_assets_x
              WHERE file_index = :P35_FILE_INDEX_DEL AND
                    case_part_id = :P35_CASE_PART_ID;

       

              :P35_FILE_INDEX_DEL := NULL;

       

              COMMIT;
          END IF;
      END;

       

      Please let me know if you have questions or if this is not clear.

       

      Thanks,

      Joe

        • 1. Re: Help Creating A Conditional Success Message 5.1
          J-Lig

          There are multiple ways to accomplish this. In one instance we populate a page item from within the stored procedure using apex_util.set_session_state(p_name => 'P12_RETURN_MESSAGE', p_value => 'Successfully added address record.'); Then, within the page process that calls the stored procedure, we set the "Success Message" and/or "Error Message" to return the text from the page item. 

          Basically, you would have some kind of condition within your pl/sql to set the text of the message page item and it can be different based on each scenario.

          • 2. Re: Help Creating A Conditional Success Message 5.1
            J-Lig

            To clarify: I just realized the screen print I attached actually goes a step further and passes the success/failure message into the closeModal page process so that the message is actually displayed on the parent page when the modal closes. You can either put it into the Success Message of the page process that calls the PL/SQL itself, or if you are using a modal, you can pass it into the Success Message of the closeModal page process like I did in the screen print. Sorry if that was confusing.

            • 3. Re: Help Creating A Conditional Success Message 5.1
              Joe R

              J-Lig,

               

              Thank you for replying.

               

              I really like this approach and it does make it easy to achieve this!

              I've started to build this and it works nicely!

               

              Thanks,

              Joe