Discussions

Expand all | Collapse all

Magic Button - add record but remain in form in edit mode

  • 1.  Magic Button - add record but remain in form in edit mode

    Posted 06-17-2019 23:14
    Hello. I have a form in which I've placed a magic button. While editing the form (i.e. in edit mode), I want a user to be able to click that button (which creates a record in a separate, non-child table) without navigating away from the form or saving the form or refreshing the form, i.e. basically I want the action to execute without doing anything to the form.

    Note: I'm aware of the table setting to have the parent record automatically save when a child record is created. I'm not talking about that. Ideally, nothing would happen to the form when the button is clicked. Is that possible?

    Thanks!


  • 2.  RE: Magic Button - add record but remain in form in edit mode

    Posted 06-18-2019 00:32
    //I tested this and it worked

    var text URL = URLRoot() & "db/" &  .... insert your add record URL here;

    "javascript:" &
    "$.get('" & 
    $url & 
    "',function(){" &
    "$.jGrowl('Record created in separate non-child table', {life: 5000, theme: 'jGrowl-green'});" &
    "});" &
    "void(0);"


    // the 5000 mean display the quiet pop up for 5 seconds.
    // and you get to control the pop up words.


  • 3.  RE: Magic Button - add record but remain in form in edit mode

    Posted 06-21-2019 21:39
    Thanks, Mark. I believe I've replicated the code, but I find that when I'm in edit mode, and I click on the magic button, the form still tries to save. For instance, if a form rule indicates that field 123 must not be blank and I click the magic button, I get a form message that the record is not saved because field 123 is blank. 

    Ideally, I want the code within the button to execute without triggering any kind of action (e.g. save) in the form itself. 

    Am I missing something? Thanks!


  • 4.  RE: Magic Button - add record but remain in form in edit mode

    Posted 06-21-2019 21:41
    Never mind. I think the trick was that within the magic button field settings I hadn't checked the box to open in a new window. Thanks!


  • 5.  RE: Magic Button - add record but remain in form in edit mode

    Posted 06-22-2019 00:12
    Ok, thx for letting me know.