Not if it's open in another window per se, but you can check the record's open state by using Get ( RecordOpenState ).
Under script control, with error trapping on, you can attempt to make an edit (such as using setfield). If the error returned is 301, you know the record is in use.
Thanks Guys, looks like the 301 trap will be the trick.
I'd recommend Mike's "RecordOpenState" suggestion. It's much cleaner. When you set data you are editing the record and changing it's Modification Date/Time and Modified By information.
yes but it seems only to work if you are in the actual window that the record is active, other wise it will return '0' in all other windows
Yes, Get(RecordOpenState) only returns the state of the record as you are creating/editing it. If another user/window is editing a record and has not saved (committed) the record, the Get(RecordOpenState) function in 'your' window will still show '0' because you have not started editing it (indeed, you can not).
Only attempting to edit will verify not-in-use.
One trick you might need (depending on the circumstances) is to 'open' the record, via script, perform various actions—via script or manually—then commit the record. That way, the record remains in use by you until the commit, rather than opening and committing with various actions, with the possibility of being interrupted by another user (or window!) performing an edit on the same record.
For some 'old school' modal dialogs, I have added 'on record commit' layout script trigger controls to prevent the user from accidentally clicking outside a field and inadvertently committing a record before they're done. That prevents the above scenario and allows for reverting changes, if desired.