Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

R5-Designer-LotusScript help??? 1

Status
Not open for further replies.

BlackHawk2

Technical User
Jan 29, 2002
124
US
I am new to Domino Lotus Script and creating Databases in Lotus Domino R5. I would like an example (I am not sure if you would use LotusScript or what) of how to do the following:

On a Form there is a Calandar field. This Field is a representation of when something will expire. I would like to recieve an e-mail when the set date in the calandar field is the is equal to the real date.

Could some one help me out with a few examples or lead me in the right direction???

Thanks
BH2
 

OK. This is how I would approach the task (other may think different though!). Firstly I'd create a dedicated view (possibly a hidden one) showing all documents created with that particular form. In simple terms, I'd then create a lotusscript agent (set to run each morning) looping through every document in the view and if the dates match, add this to the body of an email document.

I have included a script which I use to perform a similar task, but I report on anything within 2 days of the expiry date and use a variable in a different view to obtain the email address to send the notification to. I also send a link back to the document in question.

You should be able to modify this to get the results you want.


Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim mail As NotesDocument
Dim rtitem As NotesRichTextItem

Print "Automated Rental Advise Check Started."

' Set db = session.CurrentDatabase
Set db = New NotesDatabase( "", "xxx.nsf" )
Set view = db.GetView( "view1" )
Set doc = view.GetFirstDocument
Set mail = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( mail, "Body" )
' Set the current date and the range for anything in the next 2 days
currentdate = Cdbl( Date )
daterange = Cdat(currentdate + 2)

While Not (doc Is Nothing)
' Check whether the item has already been returned
If doc.columnvalues(3) = "" Then
' Check whether the due back date has been entered for this item
If doc.columnvalues(2) <> &quot;&quot; Then
' If the date is now, past or within 2 days then ensure it appears in the mail notification
If doc.columnvalues(2) <= currentdate Or (doc.columnvalues(2) > currentdate And doc.columnvalues(2) <= daterange) Then
Messagebox &quot;The item '&quot; & doc.columnvalues(3) & &quot;' allocated to &quot; & doc.columnvalues(5) & &quot; should be returned on &quot; & doc.columnvalues(2) & &quot;.&quot;
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText( doc.columnvalues(3) & &quot; allocated to &quot; & doc.columnvalues(5) & &quot; should be returned on &quot; & doc.columnvalues(2) & &quot;. ==>&quot; )
Call rtitem.AppendDocLink( doc, &quot;Rental Item&quot; )
Call rtitem.AddNewLine( 1 )
flag = &quot;Mail&quot;
End If
End If
End If
Set doc = view.GetNextDocument( doc )
Wend

' Evaluate who to send the email to if the flag is set to Mail
If flag = &quot;Mail&quot; Then
mail.Subject = &quot;Automated Rental Advise&quot;
Set view = db.GetView( &quot;Keywords&quot; )
Set doc = view.GetFirstDocument
While Not (doc Is Nothing)
If doc.keyword(0) = &quot;[Rental_Email]&quot; Then
mail.SendTo = doc.values(0)
flag = &quot;Send&quot;
End If
Set doc = view.GetNextDocument( doc )
Wend
If flag = &quot;Send&quot; Then Call mail.Send( False )
End If

' A nice message to appear on the Notes log!
If flag = &quot;Mail&quot; Then
Print &quot;Automated Rental Advise Check Completed - Mail Sent.&quot;
Else
Print &quot;Automated Rental Advise Check Completed - No Mail Sent.&quot;
End If

Cheers.
 
That is great. Exactly what I was looking for.... I'll work on it and post any questions that I mifht have.
BH2
 
Spa77,

Thanks for your help. Your code was helpfull in pointing me in the right direction. Although I was not able to use it due to my lack of experiance in LotusScript I was able to create a similar agent using @function.

Thanks again for pointing me in the right direction.

BH2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top