Forum Stats

  • 3,840,201 Users
  • 2,262,573 Discussions
  • 7,901,167 Comments

Discussions

100501- non-ORACLE Exception by RAISE FORM_TRIGGER_FAILURE

Muza*
Muza* Member Posts: 31
edited Apr 3, 2014 10:01AM in Forms

I have an option to user if he select I am doing some job(in YES section), If user select 'NO' I have to stop the user from continue(in NO section). So in no section I place RAISE FORM_TRIGGER_FAILURE; in NO section.

Here if I place exception the exception raise an error message 100501, and after user press 'OK' the user still able to proceed,  If i remove the exception part the user is able to continue without any problem.

I want the raise FTF to stop the user.

Below I placed my sample code.

Thank in advance.

BEGIN

  alt_id := Find_alert('ALT_STOP_USER');

  If Id_null(alt_id) then

  Message('Cannot find the alert button ');pause;

  RAISE FORM_TRIGGER_FAILURE;

  Else

  set_alert_property(alt_id,alert_message_text,' Ask user the option');

   set_alert_button_property(alt_id,alert_button1,label,'Yes');

   set_alert_button_property(alt_id,alert_button2,label,'No');

  

   x := Show_alert(alt_id);

  If x = alert_button1 then-- YES

   --- doing my tasks here

  SET_ALERT_PROPERTY('ALT_NOTE',

                  ALERT_MESSAGE_TEXT,

                  'DONE');

  A := SHOW_ALERT('ALT_NOTE');

  Elsif x = alert_button2 then

  SET_ALERT_PROPERTY('ALT_NOTE',

                  ALERT_MESSAGE_TEXT,

                  'Exit!');      

  A := SHOW_ALERT('ALT_NOTE');

  RAISE FORM_TRIGGER_FAILURE; 

  ---need to stop user from processing further

  End if;

  End if;

EXCEPTION

  WHEN OTHERS THEN

    MESSAGE('ERROR ' || SQLERRM);

    RAISE FORM_TRIGGER_FAILURE; 

END;

Muza*

Answers

  • Bhushan53
    Bhushan53 Member Posts: 59

    The Raise form trigger failure, just fails that particular event. If you want user to restrcit from performing any further actions then,

    a. You can disable the fields(Or set the update and insert allowed props to false).

    b. Use Exit form.

    Also, instead of Alt_note alert.. use fnd_message.error.

  • CraigB
    CraigB Member Posts: 5,746

    It is always helpful to include your Forms version when asking questions in the Forum. The problem you have is because you have a generic Exception handler and you are raising a generic exception.  In other words, you are not raising a named exception and you are handle the "Un-named" exception with a "WHEN OTHERS" exception handler.  You could get away with this "Sloppy Exception Handling" in older versions of Forms, but in Forms 10g (if I remember correctly) this generates the 100501 error.  There are two ways to eliminate the error.  First: drop your WHEN OTHERS exception handler.  Second, declare a user defined exception and raise the user defined exception in place of the generic RAISE FORM_TRIGGER_FAILURE exception.  For example:

    DECLARE
        invalid_alert EXCEPTION;   
      alt_note  EXCEPTION;
    BEGIN  
      alt_id := Find_alert('ALT_STOP_USER');  
      If Id_null(alt_id) then      Message('Cannot find the alert button ');pause;     
      RAISE INVALID_ALERT;  
      Else      set_alert_property(alt_id,alert_message_text,' Ask user the option');     
      set_alert_button_property(alt_id,alert_button1,label,'Yes');     
      set_alert_button_property(alt_id,alert_button2,label,'No');     
      x := Show_alert(alt_id);     
      If x = alert_button1 then-- YES         --- doing my tasks here        
      SET_ALERT_PROPERTY('ALT_NOTE', ALERT_MESSAGE_TEXT, 'DONE');        
      A := SHOW_ALERT('ALT_NOTE');     
      Elsif x = alert_button2 then        
      SET_ALERT_PROPERTY('ALT_NOTE', ALERT_MESSAGE_TEXT, 'Exit!');              
      A := SHOW_ALERT('ALT_NOTE');        
      RAISE ALT_NOTE;          ---need to stop user from processing further     
      End if;  
      End if;
    EXCEPTION  
      WHEN INVALID_ALERT THEN     
      MESSAGE('Alert ALT_STOP_USER not found.');     
      RAISE Form_Trigger_Failure;  
      WHEN ALT_NOTE    
      MESSAGE('You have answered "NO".');    
      RAISE FORM_TRIGGER_FAILURE; 
    END;

    Craig...

  • Muza*
    Muza* Member Posts: 31

    Thanks Craig,

    I tried this method, but after alt_note message in the exception the form is available to change the data. I want the user to stop from processing further. After user select 'NO' i want user to stop continuing further and stop processing anything. But here the user is able to continue and save the data. Is there any possibility to resolve this.

  • juliojgs
    juliojgs Member Posts: 596 Bronze Badge

    If you want it to stop processing ... Why do you catch the form_trigger_failure exception? Just remove the exception section.

    SQLERRM: sqlerrm is for db raised exceptions, not for "forms exceptions". As of sqlerrm concerns, form_trigger_failure is a non oracle exception. That's the reason you get a 100501.

    If you are calling db procedures, and expect to get back a database exception to catch in when others clause, maybe you may want to catch first your forms-generated exceptions, with a

    Exception

         When Forms_trigger_failure then ...

         When others then ... message (sqlerrm)...



    Also, if this piece of code is invoked from another forms trigger or pl, you can check

    IF FORM_SUCCESS THEN ...

    (this last part I'm not very sure if is suitable to user procedures or is just intended for checking built-ins success or failure result)

  • Muza*
    Muza* Member Posts: 31
    edited Mar 27, 2014 7:35AM

    Thanks.....

    I tried without exception section as well... but still after the message section the program able to continue that's what i could not figure out.

    I did not get what you trying to explain in the second section

    "

    Also, if this piece of code is invoked from another forms trigger or pl, you can check

    IF FORM_SUCCESS THEN ...

    (this last part I'm not very sure if is suitable to user procedures or is just intended for checking built-ins success or failure result

    "

  • CraigB
    CraigB Member Posts: 5,746
    edited Mar 27, 2014 10:31AM

    Muza,

    Muza* wrote:
    
    ... I want the user to stop from processing further. After user select 'NO' i want user to stop continuing further and stop processing anything. But here the user is able to continue and save the data. Is there any possibility to resolve this.
     

    This being the case, I would set a variable when you raise the ALT_NOTE exception.  Then in your Key-Commit trigger check the value of the variable to determine whether to allow a commit or not.  For this kind of "Form Global" variable, I don't like using a true GLOBAL because the variable doesn't need to be seen by anyother Form but the current form.  You could use a Parameter object or you could use a Forms Program Unit package (my perferred method) to store the variable.  This make the variable visible to the entire form, but not the entire application.  For example:

    /* This package stores variables I need throughout the form,
    but don't need these variables to be visble outside of the current form. */
    PACKAGE Form_Vars IS
      PROCEDURE Set_Commit_Allowed (p_allowed BOOLEAN DEFAULT TRUE);
      FUNCTION Is_Commit_Allowed RETURN BOOLEAN;
    END Form_Vars;

    PACKAGE BODY Form_Vars IS
    -- Global Package Variables
      G_Commit_allowed     BOOLEAN := TRUE;

      PROCEDURE Set_Commit_Allowed (P_allowed BOOLEAN DEFAULT FALSE) IS
      BEGIN
      IF ( P_allowed ) THEN
      G_Commit_Allowed := TRUE;
      END IF;
      END Set_Commit_Allowed;

      FUNCTION Is_Commit_Allowed RETURN BOOLEAN IS
      BEGIN
      RETURN G_Commit_Allowed;
      END Is_Commit_Allowed;
    END Form_Vars;

    So, this is my pacakge to set and read if a Commit is allowed.  Now, let's modify the previous code sample I posted to use this package.

    ...
    EXCEPTION
       WHEN INVALID_ALERT THEN
            MESSAGE('Alert ALT_STOP_USER not found.');
            RAISE Form_Trigger_Failure;
       WHEN ALT_NOTE
            MESSAGE('You have answered "NO".');
            Form_Vars.Set_Commit_Allowed;
            RAISE FORM_TRIGGER_FAILURE;     
    END;

    Now that the variable has been explictly set, now you can alter (or create) the Key-Commit module level trigger...

    /* Sample Key-Commit trigger */
    BEGIN
      IF ( Form_Vars.Is_Commit_Allowed ) THEN
      -- Perform any commit processing you need here.
      -- Could just simply be COMMIT_FORM;
      ELSE
      -- Commit not allowed.
      -- Display appropriate message here
      Clear_Message;
      Message('You answered NO earlier. Commit is not allowed.');
      Message(' ' ); -- This empty string will promote the message to the Default Alert
      RAISE Form_Trigger_Failure;
      END IF;
    END;

    This should prevent the user from commiting your form when they answer NO to your previous Alert.  At some point in your Form, after the user has answered NO, and they have satisfied some criteria, you will want to set the G_COMMIT_ALLOWED package variable to TRUE so they can perform the needed commit.

    Hope this helps.


    Craig...

    Message was edited by: CraigB

    Muza*
  • Andreas Weiden
    Andreas Weiden Member Posts: 10,871 Gold Crown

    If you don't want the user to do any processing in the forms anymore, why don't you just close the form?

  • Muza*
    Muza* Member Posts: 31

    Dear Craig,

    Simply I maintain a global variable. When user select NO I set it to N and then in the KEY COMMIT I check and do as you suggest. But here if user try to do save and it fires. For me I want when he select No stop the user to view/ edit the record. And stop the user doing anything in that particular record.

    Dear Andreas,

    Close_form is not valid in WVI level..

  • CraigB
    CraigB Member Posts: 5,746
    Muza* wrote:
    ...Simply I maintain a global variable. When user select NO I set it to N and then in the KEY COMMIT I check and do as you suggest. But here if user try to do save and it fires. For me I want when he select No stop the user to view/ edit the record. And stop the user doing anything in that particular record.... 
    

    Muza,

    You won't be able to do that because you can't prevent the Key-Commit event from happening; you can only limit what the event is allowed to do when it occurs.

    Craig...

This discussion has been closed.