13 Replies Latest reply: Oct 20, 2009 7:53 PM by 728143 RSS

    Raise Form_Trigger_Failure Question

    elmousa68
      I think I know part of the answer, but just to make sure:

      Is there a difference between having Raise Form_Trigger_Failure in the body of a trigger as opposed to placing it in the exception section?

      Ammar
        • 1. Re: Raise Form_Trigger_Failure Question
          728143
          Hi All,

          even i have the same doubt. can someone clarify?
          i have written the raise form_trigger_failure in both the if loop and also at the exception at the
          below of my block.
          Will it affect the code?
          the raise form_trigger_failure is not getting triggered nw..
          can some one advice on this issue?
          • 2. Re: Raise Form_Trigger_Failure Question
            Arunkumar Ramamoorthy-Oracle
            Hi,

            It depends on the requirement and the coding standard you follow.

            For ex, in your when-validate-item trigger, if you are checking for the value entered in some other field (say using if condition), and based on that, you want to restrict the user, you will use it in trigger body.

            However, if you are querying a table and based on the data retrieved, (say WHEN NO_DATA_FOUND) you might want to restrict the user, you would be using that in EXCEPTION.

            Anyways, it does not matter where you raise the FORM_TRIGGER_FAILURE, the execution of the trigger will terminate there itself. So, Its upto you to decide where you want to put ;-)

            -Arun
            • 3. Re: Raise Form_Trigger_Failure Question
              728143
              hi arun,

              thanks.
              below is my code


              IF v_status<>'PRODUCTION' THEN
              FND_MESSAGE.SET_STRING('The item status is Not Production.'||chr(10)||
              'A Scheduling OR Cancel Action has been triggered. '||chr(10)||
              'Do you want to continue with the transaction?'||chr(10)||
              'Item Type : '||v_item||chr(10)||'Item Status : '
              ||v_status||chr(10)||'Item Product Line: '||v_item_line||chr(10)||'Planner Name : '||v_name);
              l_button_selected:=fnd_message.question(button1 => 'Cancel',
              button2 => 'No',
              button3 => 'Yes',
              default_btn => 2,
              cancel_btn => 1,
              icon => 'question');
              fnd_message.show;

              IF l_button_selected = 1 then -- 1 cancel
              FND_MESSAGE.SET_STRING('This is a test message confirmation_1'||l_button_selected);
              fnd_message.show;
              Raise Form_Trigger_Failure ;
              END IF;

              IF l_button_selected = 2 then -- 2 No
              FND_MESSAGE.SET_STRING('This is a test message confirmation_2'||l_button_selected);
              fnd_message.show;
              Raise Form_Trigger_Failure ;
              END IF;

              IF l_button_selected = 3 then -- 3 Yes
              FND_MESSAGE.SET_STRING('This is a test message confirmation_3'||l_button_selected);
              fnd_message.show;
              NULL;
              END IF;

                   END IF;
                   END IF;
                   EXCEPTION
                                  WHEN OTHERS THEN
                                  FND_MESSAGE.SET_STRING('This is a test message from the exception block'||l_button_selected);
                             Raise Form_Trigger_Failure ;          
              END;

              This is the code and the raise form_trigger_failure is not gettin raised.
              can u help me in this scenario.
              the workin of the code is there are three buttons, when the user clicks on No or cancel, there should not be any changes in the form and wen we press OK, the
              changes shud be saved.
              let me know if you have any quuestion.
              thanks in advance...

              lekshman
              • 4. Re: Raise Form_Trigger_Failure Question
                725341
                hi
                check if fnd_message.question returning Some value or not
                • 5. Re: Raise Form_Trigger_Failure Question
                  728143
                  hi,
                  the messages written inside the if were working fine, but the only issue is that the raise form_trigger_failure is not being raised.
                  im clueless..:(
                  • 6. Re: Raise Form_Trigger_Failure Question
                    618632
                    Hi!

                    Because you raise the form_trigger_failure the exception form_trigger_failure is raised
                    and your others exception handler catch this exception ...
                    do you get me?

                    so change your exceotion handler to:
                    exception when form_trigger_failure then raise;
                    when others then FND_MESSAGE.SET_STRING('This is a test message from the exception block'||l_button_selected);
                    Raise Form_Trigger_Failure ; 
                    • 7. Re: Raise Form_Trigger_Failure Question
                      728143
                      hi magoo,

                      i have done watever u have said. im jus hoping that wud be rite.. i will know the result in some 20 mins..

                      thanks,
                      Lp
                      • 8. Re: Raise Form_Trigger_Failure Question
                        728143
                        hi magoo,

                        sorry :( the code abuv was not wrkin ... i know tat we are vry near to the soln, bbut nt gettin the rite one..

                        this code was not going to the exception part itself.. :(

                        please advice..
                        • 9. Re: Raise Form_Trigger_Failure Question
                          CraigB
                          Ammar,
                          You asked:
                          Is there a difference between having Raise Form_Trigger_Failure in the body of a trigger as opposed to placing it in the exception section?
                          The difference between RAISE Form_Trigger_Failure and the EXCEPTION section is that you are explicitly raising an exception versus responding to an exception. Calling RAISE Form_Trigger_Failure is analogous with RAISE_APPLICATION_ERROR in a database procedure.

                          For example, say you have a Forms When-Validate-Items trigger that performs a duplicate value check on a field. If the user enters a duplicate value, typically you would want to stop all processing in your Form until the value entered passes this duplicate check. To stop all other triggers that normally fire after the When-Validate-Item, you have to RAISE an exception.

                          Then, like Magoo stated, you can handle this exception in the EXCEPTION section.

                          Hope this helps.
                          Craig...

                          If my response or the response of another was helpful, please mark it accordingly
                          • 10. Re: Raise Form_Trigger_Failure Question
                            728143
                            hi all,

                            my abuv code is not wrkin even after many changes..

                            can some1 help me??
                            • 11. Re: Raise Form_Trigger_Failure Question
                              AmmadAhmed
                              Hi,
                              Put any message before the first IF condition. And b/w all IF conditions mean put on message
                              e.g. (message('1');pause; message('2');pause;...
                              Then check then after which step coding is stuck. I think your called function is giving error...please first follow
                              these steps and let me know...

                              -Ammad
                              • 12. Re: Raise Form_Trigger_Failure Question
                                618632
                                Hi!

                                Could you please check what your fnd_message.question function returns?

                                May you have to change the code to use the alert_button constants:
                                if
                                  l_button_selected = alert_button1
                                then
                                  FND_MESSAGE.SET_STRING('This is a test message confirmation_1'||l_button_selected);
                                  ...
                                Regards
                                • 13. Re: Raise Form_Trigger_Failure Question
                                  728143
                                  hi all, the code is wrkin fne nw..it was because i added the raise form_trigger_failure onli at the exception handled at this block.

                                  the same needs to be handled at all the exceptions below this code, for the exception to skip totally from the block and thus does not save any changes.

                                  Thanks ppl...