Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Ignoring exiting events

Posted on 1999-08-11
27
Medium Priority
?
327 Views
Last Modified: 2013-12-18
I have a form with several fields that run script on the exit event from the field.  The script worked fine until I copied the fields into a new form.  In the new form, the script looks fine but does not run when the user exits from the field.  Any ideas how to get it running again (and why it's stopped working)?

I don't think the script is at fault but here is an example:

Sub Exiting(Source As Field)
     
     Dim doc As notesdocument
     Dim uidoc As notesuidocument
     Dim ws As New notesuiworkspace
     Dim lsTempPrice As Variant
     Dim evalTotalLocal As Variant
     Dim evalTotalUSA As Variant
     
     Set uidoc=ws.currentDocument
     Set doc=uidoc.Document
     lsTempPrice=uidoc.fieldGetText("Price_1")
     
     If lsTempPrice<>"" Then
          evalTotalLocal=Evaluate("@sum(Quantity_1*Price_1)",doc)

          Call doc.ReplaceItemValue("Total_local_1",evalTotalLocal)
          evalTotalUSA=Evaluate("@Sum(Total_local_1*@TextToNumber(ExchangeFactor))",doc)

          Call doc.ReplaceItemValue("Total_USA_1",evalTotalUSA)
     End If
     
End Sub
0
Comment
Question by:pentapod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 11
  • 2
  • +2
27 Comments
 
LVL 2

Expert Comment

by:Paebdb
ID: 1120354
You should check with the debugger if the inner loop is getting executed.
If there is no field "Price_1" on your new form, lsTempPrice stays empty and the loop is not being entered.

Anyhow it should be easy to find out by using the debugger, to see if the exit event is skipped totally, or if in it something is going wrong.
0
 
LVL 3

Expert Comment

by:MW
ID: 1120355
Hmmm, which Notes version are you running. I remember that there was a bug in older R4 version when copying fields re the Entering and Extiting event script.

If you do not have any differences in the script, why don't you create a shared field and insert a shared field into your new form.

Makes it even easier to maintain
0
 

Expert Comment

by:JeffNJ
ID: 1120356
An extension to MW's comment, you may want to consider using a subform.

Also, does the new form have "Automatically refresh fields" selected?  I know you need that selected to get Notes formulas to run, but I don't know if you need it for the Exiting event or not.

Here is a trick I sometimes use to find slight differences between two objects.  Do a design synopsis and select *only* the first (working) form.  Select the entire synopsis and paste it into MS Word.  Save the file.  Do another design synopsis and select *only* the second, non-working form.  Paste the entire synopsis into MS Word.  In MS-Word, select Tools, Track Changes, and Compare Documents.  Compare the two synopsii (or is that synopses?).  I know this is tedious, but I find slight differences in things this way occasionally.

I hope this helps.

-Jeff
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:pentapod
ID: 1120357
Thanx for the suggestions.  In order:

1.  The exiting event is getting executed - I just ran through it to confirm - it gets the values, calculates them, and does the replaceItemValue fine.  I looked in the Doc properties under Items and found the Total_USA_1 field, the value was updated there just fine.  No problems with the code, but when it's finished, it exits the subroutine and despite what shows up under the Items properly, the actual field on the document has not been changed!

2.  Am using Notes 4.6.2a, quite up to date.  And, I'm not actually sharing the script with another form in the same database so I didn't bother with shared fields.

3.  Yes it does have "automatically refresh fields" enabled and I'm not using a subform because I want to email the document with the form stored and I wasn't sure what happened with subforms in this case so I decided not to complicate things.

A mystery, a mystery, I need to take a more advanced Notes training class (only have AppDev1) but unfortunately am living in Brazil at the moment...

... Pentapod (and the idea of learning LotusScript in Portuguese just boggles the mind)
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1120358
When u copied the fields into the new form, was it completly new, or did u add a field, then delete it, then pasted those new fields? And why dont u just change the name of the field in question, I'm sure it will work then!
0
 
LVL 2

Expert Comment

by:Paebdb
ID: 1120359
Hmm, looking at the script you pasted, did you try to call the uidoc.Refresh method at the end of the script ?
0
 
LVL 1

Author Comment

by:pentapod
ID: 1120360
1.  The form was not new, it was a form copied from another database, I added lots of fields that were new to this form.

2.  Sadly calling uidoc.refresh at the end of the script causes errors because some fields have validation formulas, plus, I have about 30 similar events and refreshing after EACH of them would surely cause some performance issues?  I do have @command([viewRefreshFields]) among other things under the final "submit" button they press to save it.
0
 
LVL 1

Author Comment

by:pentapod
ID: 1120361
Oh yeah, and renaming the fields would be such an incredible headache I am not even considering the possibility.  About 30 fields would have to be renamed, code behind all of them would have to be changed, and a couple of other buttons and stuff would need to be changed too.  Ack.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1120362
I didnt say rename field'S' I said rename the field in question, the one that will receive the result!!!
And this is the problem, coz the form is not new, there must have been confusion in field naming!
And anyway, if u say that the field is updated when u see it in the document property, then calling uidoc.refresh will not make a difference!
0
 
LVL 1

Author Comment

by:pentapod
ID: 1120363
Renaming the field that receives the result makes no difference.  There is no confusion in field naming, no duplicates, no problems like that.

Aaahhhh!!  It should work!  It doesn't!  Why!!!  Aaaaaaaaahh!
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1120364
did u change the name and tried?
look I knew that it wasnt a fresh form that u copied the fields too, coz IT IS the problem!
0
 
LVL 1

Author Comment

by:pentapod
ID: 1120365
Yes, I changed the name and tried.  It did not work.  In the last bit of the code I copied above, I changed it to the following:

---
 If lsTempPrice<>"" Then
     evalTotalLocal=Evaluate("@sum(Quantity_1*Price_1)",doc)
     Call doc.ReplaceItemValue("Totallocal_1",evalTotalLocal)
     evalTotalUSA=Evaluate("@Sum(Totallocal_1*@TextToNumber(ExchangeFactor))",doc)

     Call doc.ReplaceItemValue("TotalUSA_1",evalTotalUSA)
End If
---

As you see I changed both Total_local_1 and Total_USA_1 in the code and yes I also changed the names of the fields on the form to match.  Nothing!

0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1120366
can u send me this db, or copy the form in an empty db and send it?
0
 
LVL 1

Author Comment

by:pentapod
ID: 1120367
I don't see why I couldn't send it (I'll confirm with Authorities On High) with no data.  Where do I send it?  It is currently 1800 Kb in size.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1120368
ghassan99@yahoo.com
0
 
LVL 1

Author Comment

by:pentapod
ID: 2042986
I don't suppose you've had any joy...?
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2043195
ooops!:)
Sorry...I was so busy lately, if u can notice I'm not participating round here a lot either....I checked it as soon as u sent it to me, I will tell u what I found out last thing....its not actually ignoring the exit event, its not actually identifying the field itself!!! Its like the field non existent...not all fields....I promise this weekend I will take another look...
0
 
LVL 6

Accepted Solution

by:
ghassan99 earned 300 total points
ID: 2072002
Hi penatpod,
I'm sorry for the delay, today I had a chance to look at more closely at your app...
First make sure u type in those variable that start with 'Is" like "IsTempQuantity" correctly, coz in the client, the capital 'i' which is 'I' and the small 'L' which is 'l' look similar!!! so maybe u got confused at a stage.
Then if u want to see the change reflected on the current doc (the uidoc) u must refresh it from the backend doc, with this methid 'uidoc.reload'...coz how will u see the changes u r making on the backend without refreshing???
Anyway here is an example of a working exit function from one of the fields, make sure it goes to all fields:

Sub Exiting(Source As Field)      
      Dim doc As notesdocument
      Dim uidoc As notesuidocument
      Dim ws As New notesuiworkspace
      Dim iTempPrice As String
      Dim evalTotalLocal As Variant
      Dim evalTotalUSA As Variant
      
      Set uidoc=ws.currentDocument
      Set doc=uidoc.Document
      iTempPrice=uidoc.fieldGetText("Price_1")
      
      If iTempPrice<>"" Then
                            evalTotalLocal=Evaluate("@sum(Quantity_1*Price_1)",doc)
            Call doc.ReplaceItemValue("Total_local_1",evalTotalLocal(0))
                            evalTotalUSA=Evaluate("@Sum(Total_local_1*@TextToNumber(ExchangeFactor))",doc)
                            Call doc.ReplaceItemValue("Total_USA_1",evalTotalUSA)
            uidoc.reload
              End If
End Sub

I had to change the 'IsTempPrice' to 'iTempPrice' it looks more clearer in the client.

Goos Luck
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2077377
Did u try it?

I just noticed I typed Goos Luck! :)

So...Good Luck
0
 
LVL 1

Author Comment

by:pentapod
ID: 2078732
The fields didn't need renaming - just adding the uidoc.reload seems to have done the trick.  What is the difference between that and uidoc.refresh, which didn't work, and why was it working before without uidoc.reload?  The naming convention is from Access:  ls=local string.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2079246
yes I know it was nothing to do with the names, I think I misread one of those variables and wrote wrongly which also added an extra bit of hardness to debug the code:)
The 'refresh' methos will refresh the uidoc, and also will go through the validation formulas for each field, so if u refresh midway lets say, before proceeding to some fields which are required to be filled and have validation formulas inside, those formulas will get evaluated, and produce an error since the field is empty.  The 'reload' method, on the other hand, will only refresh the current values from the backend document which is set with 'uidoc.document'
I know the help file says that u dont need reload for fields accessed with the 'document' property, but I think its not always right.  I know sometimes it will refresh immediately like it says in the help file, other times it wont, I dont know exactly why, but probably if there is an RTF in the doc.
Anyway, good that its working now.

PS r u an English lady working in Brazil? (just guessing)
0
 
LVL 1

Author Comment

by:pentapod
ID: 2080985
Ahhh... weird.  Thanks, that explains it anyway.

Almost right - I'm a Canadian/British/Australian currently working in Brazil, but you'd never have guessed that!  "Lady" depends on who you ask.  ;)

....Pentapod
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2081040
Well they are all in the commonwealth, right?!:)
ok, 'Lady' or not, is it something feminine?
0
 
LVL 1

Author Comment

by:pentapod
ID: 2081227
Feminine... hmm... so rumour has it, anyway.  (Why?)
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2081284
curiosity
0
 
LVL 1

Author Comment

by:pentapod
ID: 2082419
Killed the cat, you know.  Not sure about the ghassan99.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2082462
it did?:) cats have 7 lives;)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question