You've got everything just about right, with respect to global fields and variables. If one user changes a global field, the other user will neither see nor be affected by that change and can change the field as needed. Point one: Globals don't lock records, though. Point two: While globals are not 'saved' among multiple users, you do need to be aware that globals will 'save' their contents upon being closed by FileMaker Pro when not hosted by FM Server. That means that just before you upload your file to FM Server, be sure the globals contain or do not contain data as appropriate (if any contain data, that will be the default for each user upon logging in, once hosted). You might solve this by having the globals 'cleared' via script steps in the OnLastWindowClose triggered script.
And if there are default values for any globals which you want users to start with, be sure to set them as part of an OnFirstWindowOpen triggered script in the file options so they will always contain the corect defaults.
I believe that there is actually an important distinction that needs to be teased out, given that you have mentioned IWP:
The IWP record locking situation is different from one what one comes to expect when you are used to working in a FM client multi-user environment.
Entering a global field in IWP usually will lock the entire record.
The IWP system is not discerning enough to be able to know that a user is entering just a global field and will edit only a global field. Within the "brains" of IWP, it only knows that the user has entered some field in the record, and that he or she may edit the field contents. Not knowing that the field in question is a global, IWP locks the entire record, and consequently other users will be locked from making changes to other fields of the record in question.
I'll attach a simple sample file to illustrate. The file consists of a single table with two fields: a global field, and a non-global field. There is only one record in the table. If you open the file in IWP, it should take you to a layout that only shows the global field. If you then enter that field, IWP will lock the record, and you can see this by attempting to use your FM client to try to edit the contents of the standard field. Under non-IWP circumstances you would not expect that a user editing only a global field in one session would lock another user in a different session from editing the same record. Hopefully the file will illustrate that this scenario plays out differently in IWP.
Please let me know if this is not clear enough; I hope this helps.
IwpGlobals01.zip 12.7 K
I found this out the hard way. I have a form that uses globals to create new records via IWP but only one user could be in the system at one time!
We're you able to work around this ok?
Hi Steve -
I'm going to try creating temporary records in the global file, then delete them periodically. Seems like the simplest solution, although a bit "klugey".
Your proposed solution does seem the most straight-forward.
Reading your post, it occurred to me to mention:
If you could show the user the UI in Find mode, you would be able to have them enter data into regular (i.e. non-global) fields without any concerns about record locking, and then procede with your scripting as you had originally intended.
The above said, I think I prefer the solution that you propose a little bit better -- if for no other reason, it would be more clear for another developer to be able to pick up and readily comprehend.
Very best regards,
Thanks for the feedback, Steve. The same script is used for IWP and direct FMP, so I think I'll stick with the record creation idea.