Edit

ReadCurrentRecordForWindow (windowRef)

Result type:  array

Definition:  This function may only be used in a record-editing window. Either a custom window that is automatically instantiated via the second parameter of CreateListWindow or one of the standard MoneyWorks ones.

For a custom window, the function loads the current record in the selection associated with the window, and locks it to prevent other users writing it. It returns an associative array containing the value of every field in the record (the keys of the array are the field names). If the record has a tags field, each tag is parsed out into a separate array element.

Call this function from the Before handler of your record editing window to get the data to populate your window controls with.

For custom record editing windows only, operating on User, User2, OffLedger or Lists, you can use WriteCurrentRecordForWindow to write changed values back to the database.

For a standard record editing window, such as the transaction entry window, the record is already loaded and locked; this function merely copies the original loaded field values into the array. The array values do not change if the UI field content changes while the window is open.

In v9, ReadCurrentRecordForWindow makes the returned value a window property, so multiple scripts operating on the same window will see the same result (i.e. get a reference to the exact same array).

Availability:  available within MWScript handlers.

See Also:

GetWindowProperty: Retrieve data previously stored for a windowHandle

SetWindowProperty: Store data related to a window

WriteCurrentRecordForWindow: Save a record in custom UI, or save tagged fields in standard UI