Persistent Data and DevKeys

In MoneyWorks 7 we introduced a new internal data table called "User2", specifically so that mwScripts and external plug-ins can store their own persistent data in a MoneyWorks database.

However with diverse scripts each storing their own data, there is the potential for one script to inadvertently destroy or modify data stored by another. To prevent this, records in the User2 table must be accessed using two keys: a DevKey, which is unique to a particular developer or project, and a Key which can have any value. A DevKey is allocated by Cognito to developers on request, and is an integer no greater than 65,535 (#FFFF).

Because each developer/project will have a unique DevKey, developers can use whatever values they like in the Key field, knowing that they don't have to worry about data being modified by other scripts happening to use the same value. Separate projects from one developer that each store only a little data (a few settings perhaps) can be managed under one DevKey. However it may be more sensible to use a separate DevKey for projects that store a lot of data, for example you want to log every change of address made to any customer record, or store additional information against each product record.

DevKey values of greater than #FFFF can be used freely within a specific document, but should not be used across documents as they might clash with other scripts using these unrestricted DevKeys.

Note that these are conventions only, and there is nothing to stop the ignorant or malicious using a DevKey that is not assigned to them. But we're confident that you wouldn't be one of these.

To access the User2 table, use the mwScript functions GetPersistent() and SetPersistent(). If accessing from an external system (e.g. using COM/AppleEvent/REST), use export and import.

Posted in Database, MWScript | Comments Off on Persistent Data and DevKeys