Announcement

Collapse
No announcement yet.

How to determine if form is in insert or edit mode?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to determine if form is in insert or edit mode?

    Hi,

    I need to do some conditional coding based on if a form is adding a new record or editing an existing record.

    There must be a variable somewhere that sets this, but the source code is somewhat confusing, and a lot of it is in Spanish, so it is hard to guess which one it might be.

    Thanks

    Tony

  • #2
    All is in the manual bro...


    Buttons
    sc_btn_copy
    This macro returns "true" when the "copy" button is selected in a form.
    sc_btn_delete
    This macro returns "true" when the "Delete" button is selected in a form.
    sc_btn_display ("Button_Name","on/off")
    This macro activate toolbars buttons on the application in execution time.
    sc_btn_insert
    This macro returns "true" when the "Add" button is selected in a form.
    sc_btn_new
    This macro returns "true" when the "Add New" button is selected in a form.
    sc_btn_update
    This macro returns "true" when the "Save" button is selected in a form.


    regards

    Comment


    • #3
      Thanks,

      It seems like a button property did not belong to what I was looking for and so it escaped me. However, as you said, it worked, especially after I sorted the logic out.

      Tony

      Comment


      • #4
        Glad to hear

        Regards

        Comment


        • #5
          So does "selected" mean that the button exist on the form and not that it's been selected/pressed?

          Comment


          • #6
            That is one of the reasons why it confused me at the start. But I used an if (sc_btn_new) statement to check to see if it did anything when in edit mode, and it bypassed the code in there, so it worked.

            Comment


            • #7
              Originally posted by robydago View Post
              So does "selected" mean that the button exist on the form and not that it's been selected/pressed?
              No it means it returns true when you've click on it

              Comment


              • #8
                About this question , it is possible to know in any event as like OnValidate the current mode of the form ? if a user is inserting or editing ?

                Example in onvalidate event, i need compare it.
                if (CURRENT_MODE = 'INSERT') then ....
                elseif (CURRENT_MODE = 'EDIT') then ....

                Comment


                • #9
                  Yes, with macros mentioned in this thread
                  /Giuseppe

                  Professional Scriptcase Services
                  Some Customers opinions

                  Comment


                  • #10
                    NOT WORK

                    PHP Code:
                    if (CURRENT_MODE == 'INSERT') echo 'INSERT<br>';
                    elseif (
                    CURRENT_MODE == 'EDIT') echo 'EDIT<br>';
                    else echo 
                    '?????<br>'

                    output:
                    ?????

                    error:
                    Use of undefined constant CURRENT_MODE - assumed 'CURRENT_MODE'
                    Use of undefined constant CURRENT_MODE - assumed 'CURRENT_MODE'

                    Comment


                    • #11
                      THIS WORK

                      PHP Code:
                      echo "nmgp_opcao = $this->nmgp_opcao<br>"
                      // edit
                      nmgp_opcao = igual
                      nmgp_opcao = inicio

                      // new
                      nmgp_opcao = novo

                      // insert
                      nmgp_opcao = incluir

                      // update
                      nmgp_opcao = alterar

                      // delete
                      nmgp_opcao = excluir

                      // error - nothing
                      nmgp_opcao = nada

                      Comment


                      • #12
                        I never used CURRENT_MODE, didn't noticed about this constant, and is getting you an error because this constant don't exists. Maybe comes from old SC versions.

                        For events like onvalidate I use sc_btn_new/delete and so on macros. For load, I just ask if PK has value. (if ({id}>0 ..)
                        /Giuseppe

                        Professional Scriptcase Services
                        Some Customers opinions

                        Comment


                        • #13
                          In This Tread i was asking about same question.
                          Does is possible to know in any event as like OnValidate the current mode of the form ? if a user is inserting or editing ?

                          It would be nice if the SC staff can solve this question.



                          Comment


                          • #14
                            Originally posted by alvagar View Post
                            In This Tread i was asking about same question.
                            Does is possible to know in any event as like OnValidate the current mode of the form ? if a user is inserting or editing ?

                            It would be nice if the SC staff can solve this question.


                            read my post
                            /Giuseppe

                            Professional Scriptcase Services
                            Some Customers opinions

                            Comment

                            Working...
                            X