NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: ian.burgess on February 21, 2012, 04:27:05 AM

Title: Force record to be saved
Post by: ian.burgess on February 21, 2012, 04:27:05 AM
I am still getting to grips with a web app in Nettalk and have a simple question.... I have put a "Print" button on a web form that prints a report but I need it to force the record to be saved prior to running the report - I can't fathom out what code to embed (ABC app). Can anyone point me in the right direction please? Many thanks.
Title: Re: Force record to be saved
Post by: terryd on February 21, 2012, 04:30:12 AM
Hi Ian
Haven't really looked at your issue yet but why don't you put the print button on the browse instead so that the user can only print a saved record?
Title: Re: Force record to be saved
Post by: ian.burgess on February 21, 2012, 04:33:43 AM
I thought of putting print button on browse as you suggest but I was having trouble "passing" the record ID to the report so that I only got the report of the record I wanted - suggestions welcome!

Thanks

Ian
Title: Re: Force record to be saved
Post by: Bruce on February 21, 2012, 05:44:25 AM
>> I was having trouble "passing" the record ID to the report

Create an "other" button in the browse row (not a Print button).
On the "OnClick" tab set the Procedure to call (the report procedure),
and click on the option "Include Row ID".

Then in the report, the primary key values of the browse you are coming from will be in the Value queue - eg
cus:id = p_web.GetValue('cus:id')

cheers
Bruce
Title: Re: Force record to be saved
Post by: ian.burgess on February 21, 2012, 06:00:50 AM
Thanks Bruce. I will give that a try. Are you also able to answer my original question as to how to force a form to "save" a record when clicking on the print button?

Thanks

Ian
Title: Re: Force record to be saved
Post by: Bruce on February 21, 2012, 07:32:16 AM
yes, I am able to answer that.
Title: Re: Force record to be saved
Post by: Rob de Jager on February 21, 2012, 01:12:45 PM
Hi Ian
 
>>I have put a "Print" button on a web form that prints a report but I need it to force the record to be saved prior to running the report

If the print is compulsory, I would "remove" the print button and leave the save button on the form, but when the form is saved, I would call the print report procedure at an embed point "...following disk write".

If the print is not compulsory, you can change the form's save url to open your print form or webpage.

Cheers

Rob
Title: Re: Force record to be saved
Post by: ian.burgess on February 21, 2012, 01:56:21 PM
yes, I am able to answer that.

OK great - I look forward to your answer....
Title: Re: Force record to be saved
Post by: Bruce on February 22, 2012, 05:47:08 AM
Hi Ian,

The question is simple, but the answer is complex. The short answer is, do it the way you have done it by adding a button to the browse.

The root of the problem you have comes about because you're trying to do too many things "at once". In a disconnected system (like the web) this is possible, but it gets icky.

Consider;

a) When you press a Save button, you are really "saving the form" AND "opening the browse".

b) If you had a Save-and-Print button, then you are saving the form, opening the browse AND opening a report in a separate tab. But wait the report part must come after the save part. using JavaScript it's possible, but it's gonna be icky.

c) If you have a Print button on the form (so it Saves, and Prints, but stays on the form) then you have a complication if the user does a Print, but then clicks on Cancel on the form. That'd be no good.

Many sites overcome this by taking you from the "Save" to a "thanks for buying" page, where you can then print. But it's clear the record at this point is saved, and cannot be "undone".

There's no outright trivial way to accomplish what you want (although I'm not sure if you want (b) or (c) above.) It's possible to do, by sending extra javascript to the browser, but it'd need to be fairly tailored to your setup. The print-button-in-browse option is by far the best approach because the browse is effectively the "page after record is saved".

Cheers
Bruce




Title: Re: Force record to be saved
Post by: ian.burgess on February 22, 2012, 06:10:19 AM
Thanks Bruce for your detailed explanation. I see that it makes sense to stick to the print button on the browse.

Regards

Ian