Hi Brian,
I have an example here that is based on Paul Guerette's function for LockAllFields: http://assure.ly/jMHos2.
The button just calls a custom function. The actual function is in a script object called "tidyUp", which you can access under variables in the hierarchy palette.
So have a look at the script in the button, but also the function script in the associated script object.
Hope that helps,
Niall