Solved

Field not showing the right values

Posted on 2003-12-02
10
225 Views
Last Modified: 2013-12-18
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
0
Comment
Question by:adspmo
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
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
 

Author Comment

by:adspmo
Comment Utility
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
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
By GLOBAL SCRIPT, do you mean code in the GLOBALS section of a form?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
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
 

Author Comment

by:adspmo
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
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
 

Author Comment

by:adspmo
Comment Utility
It is a Number Field Computed. I had already looked for that info

James
0
 

Author Comment

by:adspmo
Comment Utility
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
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Do you have Header in the form ? If so remove it.. this causes querysave to run twice

0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 400 total points
Comment Utility
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now