Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
Information Mgmt
New to Lotus
How to buy
Live demos
Technical library
Forums & community
Java™ technology
Open source
SOA and Web services
Web development
My developerWorks
About dW
Submit content

developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum



PreviousPrevious NextNext

RE: AdjustDay Malfunction
Willy Lorenzo 25.Jan.13 10:44 AM Lotus Notes
Applications Development 6.5.4 Windows XP

Did you step through the debugger and actually see the AdjustDay function fail? Or are you saying that AdjustDay failed because the field eqptreq doesn't have your result? I ask because those are two completely different issues.

Your primary mistake is in trying to assign NewDate, which is a NotesDateTime object, as a text value. LotusScript should be throwing an error on this line. If you're not getting an error when executing this line, its probably because there's an "On Error Goto Next" line somewhere in the code preceding the code in question.

First of all, do not useFieldGetText or FieldSetText. That is a classic newbie mistake. Don't use the UI field functions for data manipulation. Use notesdocument (as in Source.Document) and set the fields directly. The reason is twofold. First, you can set the correct datatype when working with fields. Second, the UI field functions serve a different purpose. The important feature of the UI field functions is that you don't need a field name. These functions will operate at the cursor location. THAT'S what makes them valuable. But if you're not performing true UI based operations, then you'll be better off working with the Document object. Here's the correct code...

Dim NewDate As New NotesDateTime(Today)
Call NewDate.AdjustDay(7)

If Source.Document.GetFirstItem( "eqptreq" ).DateTimeValue.LSLocalTime = Today Then
Call Source.Document.ReplaceItemValue( "eqptreq" , NewDate )
End If

But wait...there's more. Make sure the eqptreq field is a Date field. Note that this only works if eqptreq is a date with no time, so make sure there's no time in there. Also, if eqptreq if empty then you get an error. So you have to account for a missing value. Here's the code with a datatype check.

If Source.Document.GetFirstItem( "eqptreq" ).Type = 1024 Then ' or DATETIMES if using Constants
If Source.Document.GetFirstItem( "eqptreq" ).DateTimeValue.LSLocalTime = Today Then
Call Source.Document.ReplaceItemValue( "eqptreq" , NewDate )
End If
Error 1000 , "Field eqptreq does not contain a date"
End If

One final point that is optional is in the way you created NewDate. I would do it differently...

Dim NewDate As New NotesDateTime( "" )
Call NewDate.SetNow
Call NewDate.SetAnyTime
Call NewDate.AdjustDay( 7 )

The reason is in the way "New NotesDateTime" works. The parameter is a text parameter. So when you enter "Today", that date value is actually turned into text through implicit data type conversion, and then the text is converted into a NotesDateTime. It's better to eliminate any ambiguity whatsoever by eliminating the text conversion step. SetNow will set the current date and time. SetAnyTime will clear out the time so that you have a date only.

AdjustDay Malfunction (Shawn Pelletier... 25.Jan.13)
. . RE: AdjustDay Malfunction (Willy Lorenzo 25.Jan.13)
. . . . RE: AdjustDay Malfunction (Shawn Pelletier... 25.Jan.13)

Document Options

  Document options
Print this pagePrint this page

Search this forum

Forum views and search

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Advanced search

Member Tools

RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds


Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds


IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums

 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite