PDA

View Full Version : Triggering additional code when saving



SpringBox
2020-01-29, 09:04
Hi Guys

Our latest web app seems to be testing well.

One question though - when we save a new record, we then sync the info to our existing VFP system by calling a webservice. That works well but requires the users to press a "Sync" button on the web interface which is a bit clunky.

We would like to call that automatically when a new record is saved.

Anyone have any ideas how to do that?

Thanks in advance

Simon

yvonne.milne
2020-01-29, 10:16
Hi Simon,

See Triggers at database or table level (https://www.lianja.com/doc/index.php/Triggers): updates, inserts, etc.

Regards,

Yvonne

yvonne.milne
2020-01-29, 10:37
Or, from the client, the beforeupdate or afterupdate Section delegates

Event Sequences: Updating a record (web/mobile) (https://www.lianja.com/doc/index.php/Event_Delegate_Sequences#Web.2FMobile_App_7).

Regards,

Yvonne

SpringBox
2020-01-31, 09:13
Thanks Yvonne - sounds like just what we were looking for.

Will give it a try

Cheers

Simon

SpringBox
2020-02-19, 08:42
Hi Yvonne

We have tried this but cannot make our tablename_onafterinsert fire.

We have a prg file we want to fire / run (from server side) whenever a new record is added to a particular table in our web app.

In the tablenme_onafterinsert we hve a simple DO xxx.prg.

We can run the xxx.prg from the console fine but not from the table trigger

Any thoughts?

Thanks in advance

Simon

SpringBox
2020-02-19, 08:59
Hi Yvonne

Update

We cannot get ONAFTERINSERT or ONAFTERUPDATE to work at all by using the GUI but we can set the constraints in code and they fire.

Interestingly, constraints made in code do not show up in the table triggers GUI.

However, what we are trying to do is fire our prg when the user presses the save / tick button on the user interface.

ONAFTERINSERT is too early and ONAFTERUPDATE can be triggered by combo boxes with data mapping in place - again too early.

How can we trigger code when the user saves the record? We don't mind if it is a new record or an existing record.


Thanks

Simon

yvonne.milne
2020-02-19, 12:03
Hi Simon,

Try the Database Events: https://www.lianja.com/doc/index.php/Database_Events. The table name is passed to the program.

If you have an example of the combobox with datamapping causing an update trigger to run, please submit a ticket, as I am not seeing this.

Regards,

Yvonne

SpringBox
2020-02-25, 09:04
Hi Yvonne

Ticket submitted.

Thanks in advance

Simon