Solved

An Agent that will create dox and archive old ones

Posted on 2003-12-09
20
308 Views
Last Modified: 2013-12-18
Hi Guys


What I m going to need to at year end is run an agent that will examine the different documents and based on a date and status would archive documents to a archive database.
Part two may be harder

I will need it to create new documents based on the Name field and a formula that wpild look at the number or remaining vacation days. Any days from 1 to 5 would be brought as CarryOver days any thing over 5 would become 5 and then refresh the document.

Is this a monster or easily done

I need this for year ends


James
0
Comment
Question by:adspmo
  • 10
  • 9
20 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9907430
I don't think I can give full working code here.. but here is the sample that you can extend

DateStr = "01/01/2003"     ' You can receive this string using Inputbox method so no hardcode is necessary
Dim session as New NotesSession
dim db as NotesDatabase
dim col as NotesDocumentCollection
dim doc as notesdocument, vac as notesdocument
dim cutoff as New NotesDatetime( DateStr )

set db = session.CurrentDatabase
searchstr = {FORM = "Vacation" & ArchiveBit = 0 | @isUnavailable(ArchiveBit)}
set col = db.Search( searchstr, cutoff, 0)
set doc = col.GetFirstDocument
While not doc is nothing
' Set Archive flag so that the scheduled or someother agent can copy it to another db and delete it
if Datevalue(cstr(doc.Created)) = DateValue(DateStr) then ' Archive Flag
   doc.ArchiveBit = 1      ' Whatever archive status that you are using
   doc.Save true, false
end if
' Now new vacation document..
set vac = db.CreateDocument   ' Create vacation doc for next yr
vac.Form = "Vacation"
if doc.VacationRemaining(0) > 5 then           ' I believe it is a number data type field
   vac.CarriedOver = 5
else
   vac.CarriedOver = doc.VacationRemaining(0)
end if
vac.ComputeWithForm true, false
vac.save true, false
set doc = col.GetNextDocument(doc)

Wend

~Hemanth
0
 

Author Comment

by:adspmo
ID: 9907874
Thanx I will start playing with it
0
 

Author Comment

by:adspmo
ID: 9957602
Here is what I have come up with so far

Sub Initialize
      DateStr = "01/01/2003"     ' You can receive this string using Inputbox method so no hardcode is necessary
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim col As NotesDocumentCollection
      Dim doc As notesdocument, vac As notesdocument
      Dim cutoff As New NotesDatetime( DateStr )
      
      Set db = session.CurrentDatabase
      searchstr = {FORM = "AvailHolidays" & ArchiveBit = 0 | @isUnavailable(ArchiveBit)}
      Set col = db.Search( searchstr, cutoff, 0)
      Set doc = col.GetFirstDocument
      While Not doc Is Nothing
' Set Archive flag so that the scheduled or someother agent can copy it to another db and delete it
            If Datevalue(Cstr(doc.Created)) = Datevalue(DateStr) Then ' Archive Flag
                  doc.ArchiveBit = 1      ' Whatever archive status that you are using
                  doc.Save True, False
            End If
' Now new vacation document..
            Set vac = db.CreateDocument   ' Create vacation doc for next yr
            vac.Form = "AvailHolidays"
            If doc.AllowanceAH_2(0) > 5 Then           ' I believe it is a number data type field
                  vac.CarriedOverAH = 5
            Else
                  vac.CarriedOverAH = doc.AllowanceAH_2(0)
            End If
            vac.ComputeWithForm True, False
            vac.save True, False
            Set doc = col.GetNextDocument(doc)
      Wend
End Sub


I am getting a typemismatch on this line

I have played around with it ,still getting the error

James
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9958207
Which line ?
0
 

Author Comment

by:adspmo
ID: 9958266
Duh


Cut no paste!!!

If doc.AllowanceAH_2(0) > 5 Then          
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9958300
Probably it is a text field

Convert it to number before comparing

If cint(doc.AllowanceAH_2(0)) > 5 Then          
0
 

Author Comment

by:adspmo
ID: 9958431
Same error, All the fields that are recording this info are number type
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9958678
Can you debug and see the value in the debugger has legal value ?
0
 

Author Comment

by:adspmo
ID: 9958885
Doc seems to be picking the wrong form
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9959528
Is the searchstr formula

{FORM = "AvailHolidays" & ArchiveBit = 0 | @isUnavailable(ArchiveBit)}


is correct ?

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:adspmo
ID: 9959744
As far as the form name goes YES

The ArchiveBit doesn't exist

That is a virtual Field is it not

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9960209
Yes it is a virtual field.

Modify the search string like this (notice brackets)
{FORM = "AvailHolidays" & (ArchiveBit = 0 | @isUnavailable(ArchiveBit))}


Then how did you conclude that doc is picking different form ?
0
 

Author Comment

by:adspmo
ID: 9965349
I looked at Doc in the Debugger variables under Items and the field names were from a different form

0
 

Author Comment

by:adspmo
ID: 9965510
Hi

It gets to
While doc is Nothing and then jumps to End Sub

Sub Initialize
      DateStr = "12/12/2003"     ' You can receive this string using Inputbox method so no hardcode is necessary
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim col As NotesDocumentCollection
      Dim doc As notesdocument, vac As notesdocument
      Dim cutoff As New NotesDatetime( DateStr )
      
      Set db = session.CurrentDatabase
      searchstr = {FORM = "AvailHolidays" & (ArchiveBit = 0 | @isUnavailable(ArchiveBit))}
      
      
      Set col = db.Search( searchstr, cutoff, 0)
      Set doc = col.GetFirstDocument
      While Not doc Is Nothing
' Set Archive flag so that the scheduled or someother agent can copy it to another db and delete it
            If Datevalue(Cstr(doc.Created)) < Datevalue(DateStr) Then ' Archive Flag
                  doc.ArchiveBit = 1      ' Whatever archive status that you are using
                  doc.Save True, False
            End If
' Now new vacation document..
            Set vac = db.CreateDocument   ' Create vacation doc for next yr
            vac.Form = "AvailHolidays"
            If Cint(doc.AllowanceAH_2(0)) > 5 Then          
                  
         ' I believe it is a number data type field
                  vac.CarriedOverAH = 5
            Else
                  vac.CarriedOverAH = doc.AllowanceAH_2(0)
            End If
            vac.ComputeWithForm True, False
            vac.save True, False
            Set doc = col.GetNextDocument(doc)
      Wend
End Sub

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9966109
It means that collection object din't return anything..Copy the formula from SearchStr variable and paste it into a new empty view and see if it fetches any documents.. If so then formula is wrong.

0
 

Author Comment

by:adspmo
ID: 9966581
I checke col in the debugger and the count was 0
So you are right the collection is returning nothing
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9966680
Ok then change the search formula to this

{FORM = "AvailHolidays" & @isUnavailable(ArchiveBit)}

0
 

Author Comment

by:adspmo
ID: 9966845
Sorry no go

Just to make sure I am in the right place

I have this in a agent
I am running it against documents created with th AvailHolidays form
The create date is varied

The colection is still empty
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 500 total points
ID: 9970458
Create a view with the selection formula you want (the selection formula is the same as what you have in SearchStr).  Play with it until you get the view to show the expected documents.  Then use that formula.

If it is returning absolutely nothing, then start with only one part, e.g., SELECT Form = "AvailHolidays" - and make sure some docs are returnd.  then, piece by piece, make it more complex and more/less restrictive.  When you are done, place the final selection formula back in the agent.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9972952
The agent should be set to run once @commands
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now