Lock Item and all related Items on opening Form

What is the code equivalent of clicking the Lock button? I have an ItemType, QN, with a Classification PVN. If a user opens a PVN, I want to run code to make it lock automatically. I've tried top.onLockCommand(), but this only locks the Item itself, not the related Items. I've tried cycling through all the related Items and unlocking them one by one, but this only works if I then click the Refresh button, or close the PVN and re-open it.