It doesn't happen to me a lot, but this time, I'm dumbfounded.
I hope it's just me, on a Friday.

Please try the following little experiment (I used Notes 7):

  • Create a new form and give it a name
  • Put a field on it and call it e.g. 'Company'
  • Give this field a default value e.g. "aaaa"
  • Create a Querysave and put in the following little script:
    Sub Querysave(source As Notesuidocument, Continue As Variant)
    Call source.FieldSetText("Company","bbbb")
    Print source.Document.Company(0)
    source.Document.Dummy=""
    End Sub
  • Start the debugger
  • Preview this form
Now lets see what happens when you save the document !!
Move the debugger window a bit, so you can have a look at the field in the background.
Let's step through the Querysave code
  • Call source.FieldSetText("Company","bbbb")
    This gives the field on the form another content. Everything cool so far. You see the changes on the form.
  • Print source.Document.Company(0)
    The old value "aaaa" is printed.
    Hmm, OK, you look at the back-end document, but still weird, as the back-end document in memory should reflect the UI doc.
  • source.Document.Dummy=""
    You just create a new back-end field.
    The Company field on the form suddenly returns to its previous content !!!!
    It looks like the back-end document (in memory) is re-fetched in the UI ???
    (even if you do this with multiple fields, they are all restored)
  • exit the debugger, you don't want to save
Do you have an explanation ??
Sure, I could just avoid using front-end fields in a Querysave.
The reason I need this is that my customer wants to do an automatic 'uidoc.SpellCheck' just before saving. If I put the SpellCheck in the Querysave (followed by some back-end updates), and the user fixes some typos, all these fixes are reverted to the situation before saving.
Any Ideas ?

Category:  Lotus  Notes  Domino  | TechnoratiTechnorati: , ,