[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

Creating a scheduled Agent !!!

I need  to write an agent that loops through all the documents in a view (parent and child) and
sees if the "date_expired" field is with in 5 days of current date and then send out an email.
I would appreciate a basic skeleton code, something to start me off.
0
apparition
Asked:
apparition
1 Solution
 
HemanthaKumarCommented:
Follow this steps

1. Create new agent and enable schedule
2. Click on Add Search button and select condition By Field
3. Select the field, and select option is in the last... and set it to 5 and Click OK button
4. Click on Add Action... button in Program pane and select Send Mail Message and set necessary parameters.

Save the agent and test

~Hemanth
0
 
p_parthaCommented:
Are u looking for something like this:


      Dim session As New notessession
      Dim db As notesdatabase
      Set db = session.currentdatabase
      Set view = db.getview("<yourviewname>")
      Set doc  = view.getfirstdocument
      While Not doc Is Nothing
            dates = "10/27/2003" ' instead of this replace it iwth ur doc.<fieldname>
            Set t = New notesdatetime(dates)
            Set t1 = New notesdatetime(Today)
            If t1.TimeDifference(t)/86400 > 5 Then
                  Set maildoc = db.createdocument
                  maildoc.form = "memo"
                  maildoc.subject ="<somesubject>"
                  Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
                  Call rtitem.AppendDocLink _
                  ( view, view.Name & " in " & db.Title )
                  maildoc.send False
            End If
            Set doc = view.getnextdocument(doc)
      Wend

change the view name and the dates value...

Partha
0
 
apparitionAuthor Commented:
Partha

where do I specify the who I want to send the email to ?

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
apparitionAuthor Commented:
got it maildoc.Sendto
0
 
apparitionAuthor Commented:
heres the code I'm using, but I'm getting a type mismatch error

Sub Initialize
      Dim session As New notessession
      Dim db As notesdatabase
      Set db = session.currentdatabase
      Set view = db.getview("Label Management")
      Set doc  = view.getfirstdocument
      While Not doc Is Nothing
            dates = doc.fldExpiry ' instead of this replace it iwth ur doc.<fieldname>
            Set t = New notesdatetime(dates)
            Set t1 = New notesdatetime(Today)
            If t1.TimeDifference(t)/86400 < 5 Then
                  Set maildoc = db.createdocument
                  maildoc.form = "memo"
                  maildoc.subject ="Expired Docs"
                  maildoc.SendTo ="Jon Doe"
                  Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
                  Call rtitem.AppendDocLink _
                  ( view, view.Name & " in " & db.Title )
                  maildoc.send False
            End If
            Set doc = view.getnextdocument(doc)
      Wend
      End SubNavigator
End Sub

Also, I need to send a list of all the expired documents in one email
not a separate email for each expired doc.

Thanks for your help
0
 
qwaleteeCommented:
Hemantha's code wll work much better for you, and you can set an action to send newsetter, which will show the results as a document with a docLink to each found item.
0
 
apparitionAuthor Commented:
I would ideally want  to get p_partha's code to work.

0
 
apparitionAuthor Commented:
got it to work

heres the code I used

Dim session As notessession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim item As NotesItem
Set session = New NotesSession
      Set db = session.currentdatabase
      Set view = db.getview("Label Management")
      Set doc  = view.GetFirstDocument
      While Not doc Is Nothing
            Set item = doc.GetFirstItem( "fldExpiry" )
            Dim t As New NotesDateTime( item.Text)
            Dim t1 As New NotesDateTime("Today")
            If t1.TimeDifference(t)/86400 < 5 Then
                  Set maildoc = db.createdocument
                  maildoc.form = "memo"
                  maildoc.subject ="bla"
                  maildoc.SendTo ="Malik Arefin"
                  Set rtitem = New NotesRichTextItem ( maildoc, "Body" )
                  Call rtitem.AppendDocLink _
                  ( view, view.Name & " in " & db.Title )
                  maildoc.send False
            End If
            Set doc = view.getnextdocument(doc)
      Wend
0
 
p_parthaCommented:
sorry,
I didn't get any mail that comments were added, so cudn't see the posts...

thx for the points

Partha
0

Featured Post

Independent Software Vendors: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now