Announcement

Collapse
No announcement yet.

Save from code?

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

  • Giu
    started a topic Save from code?

    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.

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

    Leave a comment:


  • Giu
    replied
    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

    Leave a comment:


  • scriptcaser
    replied
    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.

    Leave a comment:


  • jsbinca
    replied
    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

    Leave a comment:


  • Giu
    replied
    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.

    Leave a comment:


  • scriptcaser
    replied
    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. :-)

    Leave a comment:


  • Giu
    replied
    it's a button in toolbar. Before I do some tasks, I want to make sure data in form si saved

    Leave a comment:


  • scriptcaser
    replied
    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.

    Leave a comment:


  • Giu
    replied
    Hi all,

    I would like to retake this. Some ideas?

    Leave a comment:


  • maxi
    replied
    not sure but try
    sc_commit_trans() ;

    before redir

    Leave a comment:


  • MikeDE
    replied
    hi Giu, why use sc_redir in a button, try sc_link instead?

    Leave a comment:


  • Giu
    replied
    I thought about this, but I'm not on an event, I did from a button in toolbar. I did an UPDATE query.

    Leave a comment:


  • daveprue
    replied
    I think what you want is here:

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

    Dave

    Leave a comment:


  • Kdriscoll
    replied
    You did a commit before the redirect right??
    Kevin

    Leave a comment:

Working...
X