Announcement

Collapse
No announcement yet.

Save from code?

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

  • Save from code?

    I have a form, and do some code when I call a PHP button on toolbar.

    In this method, I do some task, and have to redirect to the new document created, all is ok, but before redir, I need to put a value on a field and save.

    What is the way to go?

    P.S.: Basically is a Quote->Bill generate. When you are on a quote, you can generate a bill, but before redir to the bill created, I need to put the new id to {billAssigned} and then redir.

    PHP Code:
    {facturado} = $idDocumentoGenerado;
    sc_redir("form_documentocomercial"id=$idDocumentoGeneradogenerarReferencia=true); 
    Obviously, this works like a charm, but without saving {facturado} field.
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

  • #2
    You did a commit before the redirect right??
    Kevin

    Comment


    • #3
      I think what you want is here:

      http://www.scriptcase.net/forum/show...ll=1#post32574

      Dave
      Dave Prue
      Code Whisperer
      Lahar International Corp
      www.lahar.net

      Comment


      • #4
        I thought about this, but I'm not on an event, I did from a button in toolbar. I did an UPDATE query.
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment


        • #5
          hi Giu, why use sc_redir in a button, try sc_link instead?

          Comment


          • #6
            not sure but try
            sc_commit_trans() ;

            before redir
            Massimiliano Campagnoli

            Comment


            • #7
              Hi all,

              I would like to retake this. Some ideas?
              /Giuseppe

              Professional Scriptcase Services
              Some Customers opinions

              Comment


              • #8
                Must it happen before the redirect? If not, is this an option: have a global [QuoteID] and run an UPDATE query linking this to {BillID} (in either the quote or bill tables) in onAfterInsert in the Bill form app. This way if user cancels, there is no empty Bill record linked to the quote.

                Comment


                • #9
                  it's a button in toolbar. Before I do some tasks, I want to make sure data in form si saved
                  /Giuseppe

                  Professional Scriptcase Services
                  Some Customers opinions

                  Comment


                  • #10
                    Originally posted by Giu View Post
                    it's a button in toolbar. Before I do some tasks, I want to make sure data in form si saved
                    It's not clear to me why you cannot achieve this with the save button and redirect within your onValidateSuccess.

                    Giu, we know you are an SC guru so if you share the details, some of us can learn from your use case and not insult you with simplistic suggestions. :-)

                    Comment


                    • #11
                      Originally posted by scriptcaser View Post
                      It's not clear to me why you cannot achieve this with the save button and redirect within your onValidateSuccess.
                      Because it's a process I want to do just if user click on a button, not always when you save.

                      Giu, we know you are an SC guru so if you share the details, some of us can learn from your use case and not insult you with simplistic suggestions. :-)
                      I'm not a guru. All here have a lot to learn from each other. As we say here, with a poor translation.... There aren't stupid questions, but smart answers

                      I recapitulate.
                      There are some tasks I need to do just when the user press a button. When this button is pressed, I want to save the form first, to make sure, if user did some changes and didn't saved, are saved before the tasks starts.
                      /Giuseppe

                      Professional Scriptcase Services
                      Some Customers opinions

                      Comment


                      • #12
                        Create PHP Method i.e. save_and_redir():

                        do all your tasks here ...
                        echo "<script>nm_atualiza('alterar');</script>";
                        sc_commit_trans();
                        sc_redir(...);

                        Don't do the tasks in the button, especially when there are form fields involved.
                        You might not be able to access those fields.


                        Create a button:

                        save_and_redir();
                        sc_exit(sel);


                        That should do it.

                        jsb

                        Comment


                        • #13
                          Originally posted by jsbinca View Post
                          Create PHP Method i.e. save_and_redir():

                          do all your tasks here ...
                          echo "<script>nm_atualiza('alterar');</script>";
                          sc_commit_trans();
                          sc_redir(...);

                          Don't do the tasks in the button, especially when there are form fields involved.
                          You might not be able to access those fields.


                          Create a button:

                          save_and_redir();
                          sc_exit(sel);


                          That should do it.

                          jsb
                          Giu: pls confirm this worked.

                          Comment


                          • #14
                            Originally posted by scriptcaser View Post
                            Giu: pls confirm this worked.
                            I have it in my TODO. Didn't got the time to test it, but I will update
                            /Giuseppe

                            Professional Scriptcase Services
                            Some Customers opinions

                            Comment


                            • #15
                              Originally posted by scriptcaser View Post
                              Giu: pls confirm this worked.
                              I don't think jsb gives something doesn't work

                              Comment

                              Working...
                              X