Persistent document locking

I am trying to enforce persistent document locking in a database using programmatic approach… means use doc.lock(name. false)

from testing it seems that the lock call will not work on and after queryopen… because the persistent-temporary lock already take place??

so, I am thinking to force user to user an action button to initiate the editing…

Right now, the only way I can think of forcing an action button editing will be using some sort of environment variable to let the form know if its been opened by an action or by user double clicking… change mode or right mouse-edit…

Did I miss anything? Is there anyway I can force form edit from an action without using environment variable/or something similar…

Thanks!

stephen