NetTalk Central

Author Topic: Save and Next button for NetWebForm  (Read 17749 times)

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Save and Next button for NetWebForm
« on: April 17, 2012, 10:48:03 AM »
Hi,
I wish to have two save functions on two different buttons on a NetWebForm. The first save function will do the standard update of the record and  return to the browse (a Save button). The second save function will save the record as well, but instead of returning the browse, the next record in the table is fetched and the NetWebForm page is generated using this record (a Save and Next button).

I believe this a common concept  (similar to the old VCR next button) and I have easily programmed the function in windows apps many times, however I not sure where to start with a NetWebForm. Has anybody done this with a NetWebForm procedure?

I do not believe the a NetWebForm page can have two save buttons on form and if you can, how would you change the name of one of the Save buttons and not the other. One idea is to add a check box that says “Edit next record when checked” and in the form’s “URL on Save” field add a CHOOSE statement to select the URL based on the check box status. The URL to itself would have parameters to trigger fetching the next record before generating the form.  But, I would much rather just have a Save and Next button, instead of a checking the check box and pressing the Save button.

Are there parameters (values) that will have to be set to when NetWebForm is generated a second time to allow update of the fetch record? The Form to Form example has the following in the URL on Save field of the first form:
Code: [Select]
SecondForm?change_btn=change&_bidv_=' & p_web.AddBrowseValue('firstform','mailboxes',MAI:PrimaryKey)I do not understand what this does, but will I need similar parameters when I call the NetWebForm again for the Save and Next function.

Should I put the code to retrieve the next record in the  NetWebForm or in the _sendfile  routine of the web handler procedure?

Thanks,
Robert Kolanko
« Last Edit: April 17, 2012, 11:39:00 AM by Rob Kolanko »

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Save and Next button for NetWebForm
« Reply #1 on: April 17, 2012, 04:52:13 PM »
I did a similar thing that you want on a mobile app where I just wanted to go straight to a form and toggle through the records.

I would experiment with using a memory form and then just adding 2 "other" type buttons to perform the actions you mean. Obviously you would need to code in your own fetch and save routines.


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #2 on: April 17, 2012, 09:37:48 PM »
Robert,

while you can have more than 1 save button on a form (you can add buttons of type "save") - they will all be the "same", so I don't think you can use this to get the effect you want.

Kevin's approach is probably the best one - you would use "other" buttons. But replicating "save" behavior, or indeed "next record" behavior will not be completely trivial. There are some very intricate actions going on under the hood to make all the embeds work, to make the form itself work, and so on.

What I recommend is that you take one of the examples, and mock up what you have in mind. Example 1 should do nicely. Don't worry about making it work, just mock up the general layout.

then post that here, and I'll see if I can add the code to support what you have in mind.

cheers
Bruce

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #3 on: April 18, 2012, 10:10:49 AM »
Hi Bruce,
As suggested, I have attached is my attempt add a “Save and Next” button on the web1 example. I changed the wizard tabs to plain tabs for ease of use in this test.  I did not change  NetWebForm  to update memory, in an attempt to keep the update as generic as possible. The “Save and Next” button actually works with validation. However after the “Save and Next” button is used the standard “Save” button no longer updates the record.  The _sendfile method to call the form again may require additional parameters to make the form work properly. Also the return statement may not be correct where it is located or if it is even necessary, I was just trying to leave before any other values were set.  Additional validation is needed when the end of file is reached, but I can add that later.
Please correct if possible.

Thanks
Robert Kolanko


[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #4 on: April 19, 2012, 06:13:51 AM »
thanks Robert - I'll give it a look.
(warning, it may take a few days - I'm out the office tomorrow)

cheers
Bruce

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #5 on: April 25, 2012, 07:49:39 AM »
Hi Bruce,
Any luck with that example?
Thanks Robert Kolanko

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #6 on: April 27, 2012, 02:00:36 AM »
sort of.
doing it elegantly is not easy. I've tried a couple approaches, but I'm not satisfied with any of them. I'll keep at it though.

cheers
Bruce

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #7 on: April 27, 2012, 06:27:06 AM »
Thanks Bruce,
When I first attempted the procedure, I thought it would be straight forward, prep the session variables the same way as the NetWebBrowse does, then use the _sendfile method to call the NetWebForm again. But obviously there is more to it than that. I really appreciate you helping me, I believe others will benefit from your work as well.

Robert Kolanko

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #8 on: May 08, 2012, 06:54:37 AM »
Hi Bruce,
Do you think that there will be a solution to this request? or will there need to be a future enhancement of Nettalk? Do you believe that there is much need for this functionality?
Thank-you for your assistance.
Robert


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #9 on: May 08, 2012, 10:42:44 PM »
Hi Robert,

I think, to do it "right" I'll definitely need to add support into NetTalk for this. It's probably "hackable" with NetTalk as it is now, but it would be ugly hand-code, and would be quite "fragile" because it would rely on a bunch of things remaining unchanged. So it's not an ideal way to do it.

With a bit of low-level support it becomes much more robust, and is likely to work for longer, and work smoother. Unfortunately I've just been over-whelmed the past while, so I haven't had much time to develop the necessary code.

>> Do you believe that there is much need for this functionality?

That's a hard question to answer, because like so many things nicer interfaces only become popular once they exist. No-one has asked for this before, but frankly that doesn't mean much. I think it definitely has a use-case - perhaps not as common as the browse-form paradigm, but useful nonetheless.

At the end of the day I only have the 4 pairs of fingers, so I'll try and get to it as soon as I can.

cheers
Bruce



Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #10 on: May 09, 2012, 08:46:26 AM »
Hi Bruce,
Thank-you for your reply. If the right solution is forth coming then I will wait as long as I can. I do not wish to be a squeaky wheel, I only wish to let you know that I am looking forward to the proper solution, even if you do not hear from me on this topic.

Actually, the ideal solution for me, would be a method to use "_SendFile"  using the NetWebForm page with the primary key to the file record in session variables and have the NetWebForm handle the record update as if it was called from the NetWebBrowse. I could use this method in other situations besides this one.

Regards,
Robert Kolanko
« Last Edit: May 09, 2012, 09:39:22 AM by Rob Kolanko »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #11 on: May 09, 2012, 11:22:40 PM »
A reminder from time to time (just adding to this thread) would be no bad thing Rob. Usually there's more to do than time to do it in, so bumping outstanding issues is a good way to get them back into the brain.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #12 on: May 19, 2012, 03:52:18 AM »
Hi Robert,

just a progress update.

>> The second save function will save the record as well, but instead of returning the browse, the next record in the table is fetched and the NetWebForm page is generated using this record (a Save and Next button).

The devil, as they say, is in the details. In this case the phrase "next record in the table" is deceptive. It implies that a sort order, and quite possibly a filter for the table has been set.

In the case of a browse / form paradygm these have been set, by the browse procedure - so we need a mechanism to hook into that. (But remember the browse is View based, so that's a complication.) If you do come from a browse you'd definitly want the browse order and filter to be respected.

On the other hand, there may be no browse - you may instead use the Form-only approach, in which case the order and filter need to be defined in the form.

Do-able, but not trivial.

cheers
Bruce

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #13 on: May 22, 2012, 10:32:30 AM »
Hi Bruce,
Thank-you for your continued effort on this issue. You are right, I have made two requests in this thread. The first “Save and Next button”  request is simpler to explain, is to be able to add a button to a form that will save the current record and get the next record in the browse without returning to the browse. If you could modify the NetWebForm template  to do this by simply adding a special button in the NetWebForm template, that would be super cool.  Thus the template would generate the code to construct the view as in the browse, then locate the position of the current record in the view, then get the next record and reload the form with this record.   

The second request would be a just to be able to do part of the first request. That would be to have capability to call a NetWebForm page (i.e. via the "_SendFile"  method)  from the same or different NetWebForm with the primary key to the file record in session variables and have the NetWebForm handle the record update as if it was called from the NetWebBrowse. Then  the programmer is responsible to get next primary record key fields for the form, such as building the view, or whatever to get the next record.  The NetWebForm template only allows a single table to be updated anyway, not the view.  One of my objectives is to do a “save and next” method. The second request, although more complex for programmer,  has more flexibility, thus I am just as happy with the second request.

Hopefully this helps you or maybe I am just rewording your comment.

Robert Kolanko

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Save and Next button for NetWebForm
« Reply #14 on: June 01, 2012, 07:13:36 AM »
Hi Bruce,
I got 2 of my 3 change request coming in 6.33, How about this one?
Thanks,
Rob Kolanko :)