Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Save() me

  1. #1
    Senior Member
    Join Date
    Jan 2014
    Posts
    369

    Save() me

    Hi Guys

    We want to call a serverside prg when the user presses the save/update tick button on the actionbar so it is automatic and much slicker, rather than needing a separate command button.

    We have tried DBC_afterinsert and DBC_afterupdate but they occur far too early

    Where is best place to tap in to the process to call our serverside prg?

    Thanks in advance


    Simon

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Simon,

    See the doc for event sequences
    https://www.lianja.com/doc/index.php...gate_Sequences

    beforeupdate or afterupdate delegate

    or alternatively you can write your own custom action for the actionbar buttons
    https://www.lianja.com/doc/index.php...es#Save_action
    Last edited by barrymavin; 2019-11-01 at 20:38.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi guys

    Almost there with this one but just need a little help please.

    When a record is added, we call a server side prg using the dbc afterupdate() and it works well. However we would like to call our procedure when a specific table is added to but cannot get any of the table triggers to fire so have to use the dbc trigger.

    However when a record is edited, we want to change the state of a flag field "exported" but that of course is a table change which calls the dbc trigger again and we end up in a loop.

    How can we call the table trigger instead? And is there any fuction we can use on the server side to establish which record has just been been edited?

    We have looked at writing bespoke page save() delegates but cannot get our heads around that in js.

    when we try, we can call the server prg but cannot control the state of the actionbar. Looked everywhere for the right syntax but cannot find it

    We have tried this

    ** update the cursor **
    Lianja.getCursor("cust").setData("exported", "N");
    Lianja.getCursor("cust").update()

    ** call server side routine
    var exportresponse = Lianja.evaluate("exportdataVT()");

    ** try to cancel the page edit but nothing happens - is the right syntax?
    Lianja.getElementByID("pcust").Edit;



    any thoughts?



    Thanks in advance


    Simon
    Last edited by SpringBox; 2022-03-19 at 11:02.

  4. #4
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Hi Simon,

    Are these the steps you tried?

    In the Data workarea, select the virtual table, select triggers, select onafterupdate (double-click). Put in the following code before the "return .T."

    replace exported with "N"
    skip 0
    Hank

  5. #5
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Hank

    Thanks for the reply.

    That makes perfect sense - the VT exists but there is no entry in the database for the virtual table - should there be one?

    We are trying to change the exported field in a normal (non VT) customer table. Our routine looks for any record with exported # Y and inserts it into the virtual table and then changes the flag back to Y. As you can see from that logic, new records get processed fine but it is amended records that we are trying to catch. Of course changing any table in the dbc calls the dbc triggers so its easy to get in to a loop.

    We cannot get any of the table level triggers to fire, only the dbc ones.

    We thought it would be more elegant to write our own page level INSERT and SAVE routines in js to which we could send the edited record primary key value as a parameter and sidestep the above but cannot find the correct syntax to control the edit status of the page and therefore the state of the actionbar.

    Cheers

    Simon

  6. #6
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Simon

    of course the VTs will be in the database if you created them with the database open.

    if not refresh the tables in the data workspace or rebuild the database from the same place.

    I can see no issue with table triggers which is what you need to be using.

    Are you updating an oledb VT from the web? It’s possible you are and maybe that’s why no table triggers are being called.

    You also have an afterupdate trigger in the UI which can be used to call a server side procedure that does what you want to do. Many ways to do this.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  7. #7
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Barry

    All of this is desktop at the moment - let's get that going first.

    After rebuilding the dbc the VT did appear in the table list. Not seen that before.

    Still cannot get the cust_onafterupdate trigger to fire.

    Is there a special way to do this? Just to see it fired we have put a siple Messagebox('Fired') in the trigger and can confirm the .prg file is in the datbase folder.

    When we change a field in the table and save it - no messagebox.

    It seems that we will end up in a loop if we re changing a field value in the program chain called from a data updatted trigger. I guess it means each amended record will have to be processd twice.

    Is our idea to write save() and Insert() page delegates a daft one? We just cannot find how to turn off the edit state. Are there ay exaples of bespoke deegates?

    Thanks in advance

    Simon

  8. #8
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Simon

    The table triggers work fine. It’s because you are updating an oledb vt,

    My understanding us that you want to update another table when an update is applied.

    Why do you want to cancel the edit mode? That’s done anyway after the update.

    you are thinking too complex about writing client save() and add() custom actions.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  9. #9
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Simon,

    I tested the table triggers with an oledb VT and they work as expected.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  10. #10
    Senior Member
    Join Date
    Jan 2014
    Posts
    369
    Hi Barry

    That is great news.

    Just downloaded latest 7.2 Beta 6 and tried again. Some good progress at this end.

    On a fresh database with 1 table and 1 field - all table triggers work as expected so our testing method was ok.

    However on our database/normal non VT table the INSERT and DELETE triggers work fine when tested from the console but the UPDATE trigger still will not fire when records updated from the console or from code.

    When the record is updated in the console we get the "Replace complete, 1 records updated" message in the output screen and the data has changed. All good.

    Can you think of anything that might be preventing the UPDATE trigger from firing? We have rebuilt the database several times.

    It is of course the UPDATE trigger we really need.

    Cheers

    Simon

    PS Interestingly tried table triggers for another table in database and none of the triggers work for that table.
    Last edited by SpringBox; 2022-03-21 at 13:44.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us