Solved

Field not showing the right values

Posted on 2003-12-02
10
230 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
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 9862360
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
ID: 9862633
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
ID: 9863596
By GLOBAL SCRIPT, do you mean code in the GLOBALS section of a form?
0
Industry Leaders: 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 46

Expert Comment

by:Sjef Bosman
ID: 9865373
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
ID: 9866532
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
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9866862
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
ID: 9866980
It is a Number Field Computed. I had already looked for that info

James
0
 

Author Comment

by:adspmo
ID: 9867438
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
ID: 9867881
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
ID: 9867893
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

Industry Leaders: 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!

Question has a verified solution.

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

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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