Field not showing the right values

This is driving me nuts

I run a script

I see the values they are the right values
I check the variable in the debugger and they are right
When the script finishes the value in the field is wrong

These are number fields
I think the script is fine ,could be something in the field

      If Not doc Is Nothing Then
            If note.type(0) = "Sick"  Then
                  tmpNewSickDays = note.SickDaysOff(0)
                  tmpSickDays = tmpNewSickDays + doc.SickDaysAH(0)
                  doc.SickDaysAH = tmpSickDays
            End If
adspmoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

qwaleteeCommented:
Dup question

Is this script within a form, an agent, or a view action button?

Form?  Try:
Dim ws as new notesUiWorkspace
ws.currentDocument.Reload

Agent or view action?  You probably need doc.save true,false
0
adspmoAuthor Commented:
this is in a Global script

It used to work up untill an hour ago
Sub Approved
      'Set the session and db variables
      Dim ws As New NotesUIWorkspace
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument, note As notesdocument
      Dim view As NotesView
      Set note = ws.CurrentDocument.Document
      Set db = session.CurrentDatabase
      Set view = db.GetView( "AvailHol")
      If view Is Nothing Then
            Msgbox "Cannot find view"
            Exit Sub
      End If
      If note.HasItem("NameFull") Then
            Set doc = view.GetDocumentByKey(note.NameFull(0)) ' KEY Value passed to view
      Else
            Msgbox "No leave document found for this employee"
      End If
      
      If Not doc Is Nothing Then
      'The conditions for processing the vacation vary greatly thus the variety of variables
      'There is a field named carry over and it may contain Carried over vacation days. These need to be used first
      'then the alloted vacation. If the Carry Over are not used by July then they are forfeited
            
            If note.type(0) = "Vacation" And  Month(note.StartDate(0)) >6 Then '
                  tmpNewDaysTotal = note.NewDaysTotal(0)    'Number of actual vacation days
                  tmpAllowanceAH_1 = tmpNewDaysTotal + doc.AllowanceAH_1(0) 'calculate the number of used vacation days
                  tmpAllowanceAH_2 = doc.allowanceAH_2(0) - tmpNewDaysTotal ' calculate the remaining vacation days
                  doc.AllowanceAH_1 = tmpAllowanceAH_1
                  doc.AllowanceAH_2 = tmpAllowanceAH_2
                  doc.totalAH_1 = doc.CarriedOverAH_1(0) + doc.AllowanceAH_1(0) 'Calculate the used vacation  days
                  doc.totalAH_2 = doc.CarriedOverAH_2(0) + doc.AllowanceAH_2(0)'Calculate the remaining vacation days
                  Goto SaveIt
                  
            Else
                  If Month(note.StartDate(0)) < 6 And note.type(0) = "Vacation" Then
                        If note.newdaystotal(0)  =< doc.CarriedOverAH_2(0) Then 'Check the carryover remaing days first
                              doc.CarriedOverAH_1 = doc.CarriedOverAH_1(0) + note.NewDaysTotal(0) 'Calculate the used carryover  days
                              doc.CarriedOverAH_2 = doc.CarriedOverAH(0) - note.NewDaysTotal(0) 'Calculate the remaining carryover days  days
                              doc.totalAH_1 = doc.CarriedOverAH_1(0) + doc.AllowanceAH_1(0)'Calculate the used vacation  days
                              doc.totalAH_2 = doc.CarriedOverAH_2(0) + doc.AllowanceAH_2(0)'Calculate the remaining vacation days
                              Goto SaveIt
                              
                        Else
                              If (doc.CarriedOverAH_2(0) <> 0)  And (note.newdaystotal(0)  > doc.CarriedOverAH_2(0)) Then
                                    tmpCarriedOverAH_2 = doc.CarriedOverAH_2(0) 'Get the current value
                                    tmpNewDay = note.newdaystotal(0) - tmpCarriedOverAH_2  'Calculate the difference between the requested and the carryover
                                    tmpAllowanceAH_2 = doc.AllowanceAH_2(0) - tmpNewDay ' calculate the remaining vacation days
                                    tmpAllowanceAH_1 = doc.AllowanceAH_1(0) + tmpNewDay  'calculate the number of used vacation days
                                    doc.CarriedOverAH_1 = doc.CarriedOverAH_1(0) + tmpCarriedOverAH_2 'Calculate the used carryover  days
                                    doc.CarriedOverAH_2 = 0 'Set the available to 0
                                    doc.AllowanceAH_1 = tmpAllowanceAH_1 'Set the values
                                    doc.AllowanceAH_2 = tmpAllowanceAH_2 'Set the values
                                    doc.totalAH_1 = doc.CarriedOverAH_1(0) + doc.AllowanceAH_1(0) 'Calculate the used vacation  days
                                    doc.totalAH_2 = doc.CarriedOverAH_2(0) + doc.AllowanceAH_2(0) 'Calculate the remaining vacation days
                                    Goto SaveIt
                              Else
                                    If doc.CarriedOverAH_2(0) = 0 Then
                                          tmpNewDaysTotal = note.NewDaysTotal(0)    'Requested days vacation
                                          tmpAllowanceAH_1 = tmpNewDaysTotal + doc.AllowanceAH_1(0) 'calculate the number of used vacation days
                                          tmpAllowanceAH_2 = doc.allowanceAH_2(0) - tmpNewDaysTotal ' calculate the remaining vacation days
                                          doc.AllowanceAH_1 = tmpAllowanceAH_1  'Set the values
                                          doc.AllowanceAH_2 = tmpAllowanceAH_2   'Set the values
                                          doc.totalAH_1 = doc.CarriedOverAH_1(0) + doc.AllowanceAH_1(0)  'Calculate the used vacation  days
                                          doc.totalAH_2 = doc.CarriedOverAH_2(0) + doc.AllowanceAH_2(0)   'Calculate the remaining vacation days
                                          Goto SaveIt
                                    End If
                              End If
                        End If
                  End If
            End If
            
            If note.type(0) = "Personal" Then
                  tmpPersonalDaysAH_2 =doc.PersonalDaysAH_2(0) - note.NewDaysTotal(0) 'Calculate the remaining personaldays
                  tmpPersonalDaysAH_1 = note.NewDaysTotal(0) + doc.PersonalDaysAH_1(0)'Calculate the used days
                  doc.PersonalDaysAH_2 = tmpPersonalDaysAH_2  'Set the values
                  doc.PersonalDaysAH_1 = tmpPersonalDaysAH_1   'Set the values
                  Goto SaveIt
                  
                  
                  If note.type(0) = "Work From Home" Then
                  End If
                  
SaveIT:
                  doc.ComputeWithForm True, False  
                  doc.save True, False
            End If      
      End If
End Sub
0
qwaleteeCommented:
By GLOBAL SCRIPT, do you mean code in the GLOBALS section of a form?
0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Sjef BosmanGroupware ConsultantCommented:
The script is much too long, therefore the algorithm is too complex. I'd like to suggest a different approach, which simplifies your calculations considerably. If I may...

You calculate vacation days differently before and after the 1st of July. These calculations are not necessary, if you do the following:
- you create an agent running on July 1st (either manually or automatically)
- this agent adds an additional vacation document if required (!)
- the vacation document will be filled with the vacation days carried over but unused

Of course, you should be able to identify that the additional vacation document is not a real vacation, so you'd probably have to set the type of the document to a certain value. This also makes it easy to hide this type in the vacation views shown to your users.

Hope this might help, although I'm maybe a little late...

Sjef
0
adspmoAuthor Commented:
Yes I mean the Globals section

This works it is just not  returning half days

It used to , I have touched nothing

The values in the Variables screen show correctly. e.g 1.5 When the script finishes it shows as 2 Should I be using some IntegerScript or something

James
0
HemanthaKumarCommented:
Check the data type and input translation of the field to see if it has some functions that might round of the values

~Hemanth
0
adspmoAuthor Commented:
It is a Number Field Computed. I had already looked for that info

James
0
adspmoAuthor Commented:
I think I got it the QuerySave is running twice

When I press the Submit button it runs and sets the right value in this case .5

It then runs again and .5 = .5 =1

How do I stop the query from running twice, Use a flag?

0
HemanthaKumarCommented:
Do you have Header in the form ? If so remove it.. this causes querysave to run twice

0
HemanthaKumarCommented:
What you can do is close the document once you save/approve leave. Flag is also OK, here I believe you set field status as approved or cancelled, check that value in your save script.. adjust the values only when status is open
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.