One instance of running form per base

kvb
kvb Member Posts: 107
edited 2004-05-28 in Navision Attain
Hi all,

is there in Nav table where i can get information about quantity of existing instances of any object(for example form)?

thanx in advance

Comments

  • RobertMo
    RobertMo Member Posts: 484
    no there isn't...
    but you can make it several ways:

    make new table: (FormID, Counts)
    in your form:OnOpen you just read the record fro new table, increase counts
    On Forms OnClose you read again and decrease number.
    you can use locking and comitting to ensure correct counts...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • RobertMo
    RobertMo Member Posts: 484
    you can also make it without new table by using singleinstance codeunit,
    On open form you try to run this codeunit (if it isn't already runing) and then you just increase some counter variable...
    Form:OnClose you decrease counter...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • janpieter
    janpieter Member Posts: 298
    With the single instance codeunit you can only see the number of instances on the current client. Not on all clients.
    In a world without Borders or Fences, who needs Windows and Gates?
  • RobertMo
    RobertMo Member Posts: 484
    :oops: oops, i missed it. so it's only first way to go...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • kvb
    kvb Member Posts: 107
    thanx for replies, guys :D

    RobertMo, in case of abnormal error OnClose trigger will not run.
    So, we will have wrong data in our new table. It`s unsuitable for me.
  • janpieter
    janpieter Member Posts: 298
    Yeah, well too be honest if we have to take in account that abnormal errors can occur i think every sollution you try will not be suitable in some way.

    You can always build a monitoring tool wich scans all the window handles below "Fin.exe". But you will only be able to get the window captions with that, no object ID.
    In a world without Borders or Fences, who needs Windows and Gates?
  • RobertMo
    RobertMo Member Posts: 484
    add a filed userid, so you have <userid><formid><count>.
    when updating counter for a user on OnOpen form, you can allways run a function that checks if some user is not conected (crashed) and you fix his count (delete rec for userid's that are not conected)

    it is not perfect, but...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • RobertMo
    RobertMo Member Posts: 484
    and you should write such code that application doesn't crash.
    believe me user we'll be happy too :lol:
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • kvb
    kvb Member Posts: 107
    RobertMo wrote:
    add a filed userid, so you have <userid><formid><count>.
    when updating counter for a user on OnOpen form, you can allways run a function that checks if some user is not conected (crashed) and you fix his count (delete rec for userid's that are not conected)

    it is not perfect, but...

    good idea, i wrote this function before you say to do it 8)
    but i run it from LogInStart function in the Codeunit 1