NetTalk Central

Author Topic: Run code When a form is completed  (Read 4079 times)

Pauly

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Run code When a form is completed
« on: August 31, 2012, 05:05:47 AM »
Hi,

In a memory form (or a table form for that matter) I simply want to run some code when the form is completed.
That is.. when the user clicks the 'Save' button, _or_ presses enter.

Try as I might, the embed point eludes me.. there just HAS to be a place when I can put some code (lets say p_web.Popup('Closing') ) that will be run any time the form is completed by the user clkicking the save button _or pressing enter.

Advice please?
Pauly

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Run code When a form is completed
« Reply #1 on: August 31, 2012, 06:51:35 AM »
PostUpdate routine in the form.

You can also embed in the Browse in the
GoFocusBack routine.

Cheers
Bruce

Pauly

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Run code When a form is completed
« Reply #2 on: September 01, 2012, 12:19:33 AM »
G'day Bruce,

I have attached an example - Can you please put 'p_web.popup('Hi Paul') in the appropriate embed point (in the procedure formproc) that will run both when the user clicks on the save button and wne the user presses enter (while in the form of course)- Buggered if I can find it.

Thanks
Pauly




[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Run code When a form is completed
« Reply #3 on: September 02, 2012, 11:36:37 PM »
Hi Pauly,

perhaps it's worth going back to your original question;

>> In a memory form (or a table form for that matter) I simply want to run some code when the form is completed.

that's in the embed point mentioned. (try putting a STOP in there, and you'll see it.)

BUT;
>> lets say p_web.Popup('Closing') ) that will be run any time the form is completed

if you want something to be "pushed" to the browser at this point, now that's a _very_ different question. Remember you are working inside a request/response environment, so you can't just "push stuff to the browser" in all cases - context becomes very important.

So maybe you need to narrow down exactly _what_ you are wanting to do in this embed point...

cheers
Bruce

Pauly

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Run code When a form is completed
« Reply #4 on: September 03, 2012, 12:19:34 AM »
Hi Bruce,

I just want some code to run - In particular, this code will be adding or updating a table record, after calculating some values from session variables. Not pushing or pulling anything. I just need a place (or two if I have to!) that will run the same code when a user either clicks on the save button, or presses enter.
By the way - the users of this application see pressing enter, and clicking on 'the button other than cancel' as exactly the same thing operationally :-)

Thanks
Paul


Pauly

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Run code When a form is completed
« Reply #5 on: September 03, 2012, 02:24:53 AM »
Maybe I will rephrase -
I want the form to be 'completed' when the user clicks save, _or_ presses enter, and I would like to run some code at that point.

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Run code When a form is completed
« Reply #6 on: September 03, 2012, 04:05:26 AM »
Hi Paul,

I do it all the time.  I use memory forms when there is a couple of related tables involved, In the Pre-Update-3End embed point I read all the records or set session values as appropriate, and then

the Validate All-2End point I do whatever I want to do with whatever happened on that form.

Cheers
Charl

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Run code When a form is completed
« Reply #7 on: September 03, 2012, 11:17:25 PM »
Hi Pauly,

The "Post" routines are ideal. PostInsert, PostUpdate, PostCopy and so on.
You can put logging in there to see them rum. eg
p_web._trace('In Post Update')

cheers
Bruce


Pauly

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: Run code When a form is completed
« Reply #8 on: September 04, 2012, 03:32:13 AM »
Thanks Guys that got it.
Small steps.
Pauly