Formula Or Lotus Script?

I am still a newbee with Lotus developing and need some advise. Here is what I need to do:I have a database where our employees enter request for time off, start date, total days, and then total time. Example they request 5 days off, total hours would be 40 and startdate would be 6/7/2004 end date 6/11/2004. I also have a holiday view in the database.

Now I have another database which I pull the above information into using lotus script. However, since I am only matching the start date which holds the total time, this database would show 6/7/2004 with a totaltime off of 40hours.

I need to break it down so that each day in this database would show 6/7/2004 8 hours, 6/8/2004 8 hours and so on.

We just converted to 6.5.1 and I saw a formula for @businessdays and I also see that we can do a loop using formula and there lies the confusion. Which will work the best? and easiest to do?

Any suggestion would be helpful.

Thanks,

Subject: Formula Or Lotus Script?

Just a thought…

In the second database, why not pull ALL the days and hours. This would ensure accurate day off and hour information is used WITHOUT having to use another formula to break down each day.

Pulling ALL the information might be easier than trying to develop another formula that might cause potential errors or problems in the event it fails.

Subject: RE: Formula Or Lotus Script?

You are saying pull all the days and hours into the second database. How? would I be storing them in that database also? Write an agent?

The second problem is that I only have a start and end date and not all the individual days between. How can I break them down? Here is my current LS for pulling the information in right now. However, if someone makes a change in the other database and they click on the button it does not update the fields. The fields are all editable.

Sub Click(Source As Button)

Dim ss As New NotesSession

Dim ws As New NotesUIWorkspace

Dim doc As NotesDocument

Dim username As String

Dim view As NotesView

Dim pdb As NotesDatabase            

Dim pdoc As NotesDocument          

Dim uidoc As NotesUIDocument

Dim datetime As NotesDateTime

Dim item As NotesItem



Dim pdocCollection As NotesDocumentCollection



Set db = ss.currentdatabase



Set uidoc = ws.currentdocument



Set doc = uidoc.document

temp = uidoc.WindowTitle 

Select Case temp

Case "Timesheet"

	username = doc.name(0)

Case Else

	username = ss.commonusername

End Select



'Go to calendar database and get employee time off

'Next line is okay when this database is on mainoffice2,still local

'Set pdb = New NotesDatabase("", "Calendar2004.nsf")



Set pdb = New NotesDatabase("mainoffice2", "Corporate/Calendar2004.nsf")

Set view = pdb.getview("Individual")

Set pdocCollection = view.getAlldocumentsbykey(username)



Set pdoc = pdocCollection.GetFirstDocument

Set item = doc.GetFirstItem("Date1")

Set datetime = item.DateTimeValue



Dim date1value As Variant

date1value = doc.Date1(0)

Dim date2value As Variant

date2value = doc.Date2(0)

Dim date3value As Variant

date3value = doc.Date3(0)

Dim date4value As Variant

date4value = doc.Date4(0)

Dim date5value As Variant

date5value = doc.Date5(0)

Dim date6value As Variant

date6value = doc.Date_1(0)

Dim date7value As Variant

date7value = doc.Date_2(0)

Dim date8value As Variant

date8value = doc.Date_3(0)

Dim date9value As Variant

date9value = doc.Date_4(0)

Dim date10value As Variant

date10value = doc.Date_5(0)



'need match up for date to date in calendar to fill in other time and type



Do Until pdoc Is Nothing

	

	If date1value = pdoc.startdate(0) Then

		doc.other = pdoc.totaltime(0)

		doc.type = pdoc.reqtype(0)

		doc.Reason = pdoc.GenReason(0)

		

	Elseif date2value = pdoc.startdate(0) Then

		doc.other2 = pdoc.totaltime(0)

		doc.type2 = pdoc.reqtype(0)

		doc.Reason2 = pdoc.GenReason(0)

		

	Elseif date3value = pdoc.startdate(0) Then

		doc.other3 = pdoc.totaltime(0)

		doc.type3 = pdoc.reqtype(0)

		doc.Reason3 = pdoc.GenReason(0)

		

	Elseif date4value = pdoc.startdate(0) Then

		doc.other4 = pdoc.totaltime(0)

		doc.type4 = pdoc.reqtype(0)

		doc.Reason4 = pdoc.GenReason(0)

		

	Elseif date5value = pdoc.startdate(0) Then

		doc.other5 = pdoc.totaltime(0)

		doc.type5 = pdoc.reqtype(0)

		doc.Reason5 = pdoc.GenReason(0)

		

	Elseif date6value = pdoc.startdate(0) Then

		doc.other_1 = pdoc.totaltime(0)

		doc.type_1 = pdoc.reqtype(0)

		doc.Reason_1 = pdoc.GenReason(0)	

		

	Elseif date7value = pdoc.startdate(0) Then

		doc.other_2 = pdoc.totaltime(0)

		doc.type_2 = pdoc.reqtype(0)

		doc.Reason_2 = pdoc.GenReason(0)

		

		

	Elseif date8value = pdoc.startdate(0) Then

		doc.other_3 = pdoc.totaltime(0)

		doc.type_3 = pdoc.reqtype(0)

		doc.Reason_3 = pdoc.GenReason(0)

		

		

	Elseif date9value = pdoc.startdate(0) Then

		doc.other_4 = pdoc.totaltime(0)

		doc.type_4 = pdoc.reqtype(0)

		doc.Reason_4 = pdoc.GenReason(0)

		

	Elseif date10value = pdoc.startdate(0) Then

		doc.other_5 = pdoc.totaltime(0)

		doc.type_5 = pdoc.reqtype(0)

		doc.Reason_5 = pdoc.GenReason(0)

		

	End If

	

	

	Set pdoc = pdocCollection.GetNextDocument(pdoc)

	

Loop



Call uidoc.refresh

End Sub

Subject: RE: Formula Or Lotus Script?

In your question you mentioned using a loop, but in this code there is no loop. See here for sample code using a loop to process dates. The purpose of the code is different, but it might give you some ideas.

Subject: Formula Or Lotus Script?

LotusScript has a debugger. That alone makes it a good idea to use LotusScript for anything complicated.

Subject: RE: Formula Or Lotus Script?

I agree 100% with Rod. Debugging LotusScript is 1000 times easier than with forumla.

As to which method is better for your particular process, a lot of that depends on what you are more comfortable with and the exact context of the problem.