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

x
?
Solved

How to update a field Part2

Posted on 2003-11-07
5
Medium Priority
?
201 Views
Last Modified: 2013-12-18
Hi All

Previous question
http://www.experts-exchange.com/Applications/Email/Lotus_Notes/Q_20789973.html

Ok now I want to subtract some numbers if a request is cancelled
Just a foot note
All fields are Number and Computed
If ApprovalStatus = Cancelled then note.TotalDaysOff(0) is reset to 0

      
      If Not doc Is Nothing Then
            doc.HolidaysAH = doc.HolidaysAH(0) - doc.TotalDaysOff(0)
            doc.RemainingAH = doc.RemainingCalc(0) +doc.TotalDaysOff(0)

            doc.ComputeWithForm True, False  
            doc.save True, False
      Else
            Msgbox "No leave document found for this employee"
      End If
      
The above does not work or works inconsitently
I think the best way would be to freate a temp variable grab values and then do the math what do you think

James
0
Comment
Question by:imjamesw
[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
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:p_partha
ID: 9702776
Little bit confused...

when you are setting a value like totalsdaysoff
just set it like this

note.totaldaysoff = 0

also... what do u mean works inconsistently, when does it fail... it;s also better to use cint before doing the math.. something like this:
doc.HolidaysAH = cint(doc.HolidaysAH(0)) - cint(doc.TotalDaysOff(0))
         doc.RemainingAH = cint(doc.RemainingCalc(0)) +cint(doc.TotalDaysOff(0) )

Partha
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9703447
I am not sure if you have given me the correct fields, let me help you to organize it

If note.ApprovalStatus(0) = "Cancelled" then  ' Check this string value is same as that for cancel operation
       note.TotalDaysOff = 0     ' This will be set in the currently opened approval doc
' Get the leave doc handle to this currently selected employee..    
     If Not doc Is Nothing Then
          doc.HolidaysAH = doc.HolidaysAH(0) - doc.TotalDaysOff(0)
          doc.RemainingAH = doc.RemainingCalc(0) + doc.TotalDaysOff(0)
          doc.ComputeWithForm True, False  
          doc.save True, False
     Else
          Msgbox "No leave document found for this employee"
     End If
End If  ' ApprovalStatus Check

James clearly specify what are the results/error that you are getting so that it will facilitate me to give you proper guidance.

~Hemanth
0
 

Author Comment

by:imjamesw
ID: 9703738
Hi Hemanth

I have it working with the following perhaps you could get more info from the code



If Not doc Is Nothing Then
            tmpHolidaysAH = doc.HolidaysAH(0) 'This is the number of days used
            tmpTotal = note.NewDaysTotal(0)    'This is the number of new days booked
            tmpNew = tmpHolidaysAH - tmpTotal  'This will reset the value removing the value that was added when approved
            doc.TotalDaysOffCalc = tmpNew 'This resets the Total days used
            
            tmpRemainingAH = doc.RemainingAH(0) ' This is the number of days remaining
            tmpRemain = tmpTotal + tmpRemainingAH ' This adds the number that was subtracted when the leave was approved
            doc.RemainingCalc = tmpRemain 'This resets the remainig days to what it was prior to the new leave being approved
            doc.RemainingAH = doc.RemaingCalc 'See above
            doc.ComputeWithForm True, False  
            doc.save True, False


Hope this  explains what I need the form to do

James
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 1200 total points
ID: 9703968
I am not sure if I understood the calculation correct ... ultimately I came to this conclusion

      ' Assuming note is the current document handle
      ' doc is the leave document of the employee
      
      tmpHolidaysAH = doc.HolidaysAH(0) 'This is the number of days used
      
      If note.ApprovalStatus(0) = "Cancelled" Then  
            note.NewDaysTotal = 0    'This is the number of new days booked--- which will be 0 if it is not approved
      End If
      
      tmpTotal = note.NewDaysTotal(0)
      tmpNew = tmpHolidaysAH - tmpTotal  'This will reset the value removing the value that was added when approved
      tmpRemainingAH = doc.RemainingAH(0) ' This is the number of days remaining
      tmpRemain = tmpTotal + tmpRemainingAH ' This adds the number that was subtracted when the leave was approved
      doc.TotalDaysOffCalc = tmpNew 'This resets the Total days used      
      doc.RemainingCalc = tmpRemain 'This resets the remainig days to what it was prior to the new leave being approved
      doc.RemainingAH = doc.RemaingCalc 'See above
      doc.ComputeWithForm True, False  
      doc.save True, False
0
 

Author Comment

by:imjamesw
ID: 9716211
That is correct

James
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

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

715 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