7 Replies Latest reply: Apr 6, 2013 1:35 AM by XeM RSS

    Commit_form is not working properly in menu

    XeM
      Dear All,

      I am facing a problem caused by commit_form. I have few forms which and one menu module attached MDI window, in the menu there is an item SAVE, code listed below.
      declare
      frm_module varchar2(300);
      begin
      frm_module:=get_application_property(current_form_NAME);
      go_form(frm_module);
      if :SYSTEM.FORM_STATUS='CHANGED' then
      do_key(COMMIT_FORM);
      else
      message('No changes to be saved');
      end if;
      end ;
      Save menu item committing changes but first it displays form default message no changes to be saved and then forms default message transaction complete....
      How i can avoid that this confusing message and i want to when if some changes are applied on a form so the button saves those changes otherwise say no changes to be saved
      Thank you!
        • 1. Re: Commit_form is not working properly in menu
          998557
          Use the below code

          IF :SYSTEM.FORM_STATUS = 'CHANGED' THEN
          :SYSTEM.MESSAGE_LEVEL := '25';
               COMMIT_FORM;
               :SYSTEM.MESSAGE_LEVEL := '10';
          END IF;

          Hope helps this
          Pavan
          • 2. Re: Commit_form is not working properly in menu
            XeM
            Hi pavan

            thank you for your reply. The problem is still not solved i set the message level accordingly but still i am getting No Changes to be saved forms default message
            Please note that its working fine when single form is running but if more then one forms are open then for each form if it has not changed the same message appears.

            Regards,
            Xem
            • 3. Re: Commit_form is not working properly in menu
              998557
              "More than one form" means what? it might be, other forms are not changed so that it is showing message.
              • 4. Re: Commit_form is not working properly in menu
                CraigB
                Your code doesn't make sense to me.
                frm_module:=get_application_property(current_form_NAME);
                go_form(frm_module);
                You're already in the current form so this instruction is redundant and could result in opening a new instance of the existing form. This new form instance would have a FORM_STATUS=QUERY or NEW.
                Pavan's suggestion should work, but you may need to also check the BLOCK_STATUS and RECORD_STATUS system variables. I have seen Forms report the FORM_STATUS = QUERY when the BLOCK_STATUS was CHANGED. Consider changing your Save Button code to something like:
                BEGIN
                  IF ( :SYSTEM.FORM_STATUS = 'CHANGED'
                      OR :SYSTEM.BLOCK_STATUS = 'CHANGED'
                      OR :SYSTEM.RECORD_STATUS = 'CHANGED' ) THEN 
                    COMMIT_FORM;
                  ELSE
                    Message('No changes to be saved.');
                  END IF;
                END;
                Hope this helps,
                Craig...
                • 5. Re: Commit_form is not working properly in menu
                  XeM
                  Thank you craig,

                  Again i am trying to explain my problem i hope i do it. I have let say 4 or 5 opened forms opened in Multi forms application (forms are opened using open_form built-in and all forms sharing same session) and among them one is active form on which user making changes and then from menu select save. Now only one form has been changed and the status of remaining opened forms are query or new, as user select save then system first throwing message of No "changes to be saved" and in the last saves and applies the changes and it displays last message changes applied and saved. As there any way that i could apply commit only on active form.
                  • 6. Re: Commit_form is not working properly in menu
                    CraigB
                    Well, as you are finding out - Forms keeps track of the changes in each form seperately. In order to issue the commit in your form that has changes, you will need to navigate back to the form with uncommited changes. Knowing which form has changes is up to you to keep track of in your application. However, as your user closes each form they will be prompted to save if there are uncommited changes.

                    If you don't want the "No Changes to apply" message to display, you can trap this message in the On-Error trigger and simply ignore it. For example:
                    /* Sample On-Error Trigger */
                    BEGIN
                      IF ( ERROR_TYPE = 'FRM' AND ERROR_CODE = 40405 ) THEN
                        NULL;
                      END IF;
                    END;
                    Craig...
                    • 7. Re: Commit_form is not working properly in menu
                      XeM
                      Thank You craig!

                      Your suggestion is working nicely. To display a custom message to user if form has not been changed i wrote few lines of code in key-commit trigger which first check if form status has been changed than calls commit_form other wise display a message to user that no changes found to be saved.

                      Regards,
                      Xem