1/06/2011

A Variation On Locking the Notes Field

There is an option in the Global Options screen that lets you lock the Note2 field is various screens so that no one can alter any text that has been moved into that field using the Append Notes button. Today I worked out a way that you can imitate that same effect on either the Notes1 or Notes2 field with the added benefit of a security level check. With this script, anyone with a security level greater than 1 cannot directly edit the Building Notes1 field. They can still add to the field however by typing into the Notes2 field and then using the Append Notes button to add that text to the existing text in Notes1. Note that the script must also disable the other Append Notes button. This script uses "Building" for the Module, "Building" for the Screen, and "Edit" for the Action:

if vartype(zpsecure) = "O" and val(zpsecure.bds) > 1
buildscreen.zp_pageframe1.page4.edtNotes1.enabled=.F.
buildscreen.zp_pageframe1.page4.notes_buttons1.move1_btn.enabled=.F.
endif

You may want to clean things up by adding another script to the "Save" action that re-enables the text to make it more readable.

For ZP SQL the script would be:

if zpsecure.bds > 1
buildscreen.zp_pageframe1.page3.edtNotes1.enabled=.F.
buildscreen.zp_pageframe1.page3.notes_buttons1.move1_btn.enabled=.F.
endif

You could also change the script to make access dependent on a user's Security Initials so that only one person had access. Do this by changing the first line to:

if zpsecure.ownerinit <> "ZPD"