LOCKTABLE issue

vaxo_jjvaxo_jj Member Posts: 54
I have 2 forms which are based on the same table. Both of them delete everything in that table on open.
I want to not allow a form to run (and delete records in the table) if another form is already opened it and filled with records.

On onOpen trigger of the forms I'm using Locktable:

TempTable.LOCKTABLE;
TempTable.DELETEALL;

But it doesn't work, they still is opening and deleting records.
How it should be?
(NAV 4.0 sp3)

Comments

  • rhpntrhpnt Member Posts: 688
    As far as I can tell you want to change NAV into a single instance ERP? You should stop doing that.

    Table locking is not an front-end but and back-end/database issue and is handled according to which database (server) is used. Lookup LOCKTABLE in the NAV online help - then move forward to topics like concurrency, optimistic/pesimistic table locking, instances...found in other documents/books.
  • kinekine Member Posts: 12,562
    You cannot do that (the transaction will end after the form is opened, thus all locks are released). Question is - why you need that? Isn't better to use same principle like in rest of the application like journals with the batches? Or what about using the table as temporary and fill the data from there into the real table when closing the form? What is the real "Why"?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • vaxo_jjvaxo_jj Member Posts: 54
    I'm using NAV 4.0 so form can't be based on temporary table (otherwise this would be the best solution).
    real why is just this - I have one available table and 2 forms which make calculations and fill this table and then display those records.

    last option is to use single instance cu to set a variable indicating that a form is open. but I think its not the best solution.
  • kinekine Member Posts: 12,562
    vaxo_jj wrote:
    I'm using NAV 4.0 so form can't be based on temporary table (otherwise this would be the best solution).

    This is not true. Form could be based on temp table since first versions if I am correct... But you need to use correctly the OnFindRecord and OnNextRecord triggers for that and one global variable... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kinekine Member Posts: 12,562
    And of course, if you pass REC when calling the form and the rec is temporary, form will not check that and if you need only read-only form...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • vaxo_jjvaxo_jj Member Posts: 54
    I meant that an option SourceTableTemporary is only from NAV 5.0.
    can u please give me an example how to use OnFindRecord and OnNextRecord triggers for that purpose?
    dik
  • kinekine Member Posts: 12,562
  • rhpntrhpnt Member Posts: 688
    vaxo_jj wrote:
    I'm using NAV 4.0 so form can't be based on temporary table (otherwise this would be the best solution).
    real why is just this - I have one available table and 2 forms which make calculations and fill this table and then display those records.

    last option is to use single instance cu to set a variable indicating that a form is open. but I think its not the best solution.

    You cannot "reserve" a table for an instance of a form! You cannot control that in the application layer. It makes no sense and violates the very basic rules of NAV development! Such "solutions" lead to the dead end of NAV programming and then it's again that "NAV crap". My advice to you is: DON'T EVEN THINK ABOUT IMPLEMENTING IT! [-X
Sign In or Register to comment.