Solved

Can I select second document or 3rd document?  As I am thinking about it, I am going to be running this for 3 shifts and want to maintain 3 documents.

Posted on 2004-09-08
10
269 Views
Last Modified: 2013-12-18
Can I select second document or 3rd document?  As I am thinking about it, I am going to be running this for 3 shifts and want to maintain 3 documents.

0
Comment
Question by:sjmmajor
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 14

Expert Comment

by:p_partha
ID: 12009854
am not sure what u are trying to convey , but to get the second document, probably u can do this:

set doc = view.getfirstdocument
set secondoc = VIEW.GETnextdocument(doc)


partha
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12010311
Ok here :)


Shcedule agents - Shcedule agents do not run on a view. Any attempt to do a getfirstdocument would be fruitless untill you have a view handle. THe method to loop thru the set of the documents eligible for run is to use the UnprocessedDocuments proeprty of the NotesDatabase class. This property returns you a NotesDocumentCollection object. See designer help to learn more on how to use this property.


From the designer help.

Read-only. The documents in a database that the current agent or view action considers to be "unprocessed." The type of agent determines which documents are considered unprocessed.

Example code:

Sub Click(Source As Button)
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim collection As NotesDocumentCollection
 Dim doc As NotesDocument
 Set db = session.CurrentDatabase
 Set collection = db.UnprocessedDocuments
 For i = 1 To collection.Count
   Set doc = collection.GetNthDocument( i )
   Set item = doc.GetFirstItem( "Approver" )
   If item.Contains( session.UserName ) Then
     doc.Approved = "Yes"
     Call doc.Save( False, True )
   End If
 Next
End Sub
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12010329
I wanna add something:


If it is fixed that there would always be only 3 documents (or only 2 always, or only 4 always), i guess you can use a view rather.

Say, you store the data in docs based on form MyForm. Have a field called seq_no in the form. Now create 2/3/4 documents as per your need. Be sure to assign sequence numbers as per your priority. Now create a view. Lets say you name it MyView. Now code your agent in this way.



Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set collection = db.GetView("MyView")

For i = 1 To collection.Count
  if i = GetShiftNo() then
     ' Perform operation
  End IF
  Set doc = collection.GetNthDocument( i )
Next



GetShiftNo is a sepearet function that allows you to identify which shift the agent is runing on. Probably you can use the Now() LS function to determine the shift.
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12010358
You may ofcourse use the GetFirstDocument and GetNextDocument methods, if you are more comforatble with that. My code just does that in a more programmatic way. Feel free to ask if you have a query.
0
 
LVL 19

Assisted Solution

by:RanjeetRain
RanjeetRain earned 250 total points
ID: 12010378
I left some error in my code up there. Here is the correct version:



Dim session As New NotesSession
Dim db As NotesDatabase
Dim vw as NotesView
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set vw = db.GetView("MyView")
Set collection = vw.GetAllDocuments()

For i = 1 To collection.Count
 if i = GetShiftNo() then
    ' Perform operation
 End IF
 Set doc = collection.GetNthDocument( i )
Next
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 19

Expert Comment

by:madheeswar
ID: 12012954
in Formulas use:

@subset(@DbColumn("":"";"";"yourVIEWname";column numberORfieldname);2)

use 2 for second document or 3 for 3rd document.
if u want last 2 and 3, then use -2 and -3 respectively.

U can use above code in Lotus Script also using Evaluate function.

-Thanks
0
 

Author Comment

by:sjmmajor
ID: 12015457
Just got back to this today.  Thanks for all the info.  Would I hard code the seq_no?  I want there to always be 3 documents which I have already created in the view.  I have a field called shift that I have 1,2, or 3 in.  GetShiftNo comes from where?  Here is a copy of the agent I was using.  How would your script fit into that?  

Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim rtitem As NotesRichTextItem
      Dim object As NotesEmbeddedObject
      Dim notestime As New notesdatetime("")
      Dim notesdate As New notesdatetime("")
      notesdate.LocalTime = Date
      notestime.LocalTime = Time
      Set db = session.CurrentDatabase
      Set doc = New NotesDocument( db )
      Set rtitem = New NotesRichTextItem( doc, "Body" )
      Set doc.ProcessDate= notesdate
      Set object = rtitem.EmbedObject _
      ( 1454 , "", "\\xxxx\xxxxxr\xxxx\xxxxxx1STnotes.xls")
      doc.Form = "1st Shift Production Report"
      doc.Subjectproductions = "xx"
      doc.productionrpt = "xxxxxx 1st Shift"
      doc.shift = "1"
      doc.createddate = notesdate.LocalTime
      doc.createdtime = notestime.LocalTime
      Call doc.Save( True, True )
      
End Sub

I have set up 3 agents.  1 for 1st, 1 for 2nd shift and 1 for 3rd shift.  I would like 1st to select 1st, 2nd to select the second document and 3rd to select the third one and replace the "body" with the appropriate attachment.

0
 
LVL 19

Accepted Solution

by:
madheeswar earned 250 total points
ID: 12015505
the below script will update the same info for all the documents in that view.
If u want to upload 3 separate attachments to every document, then use an array.
like:
dim arr(2) as string
arr(0)="pathforattach1"
arr(1)=
arr(2)=
instead of the below line,
 Set object = rtitem.EmbedObject _
     ( 1454 , "", "\\xxxx\xxxxxr\xxxx\xxxxxx1STnotes.xls")
use:
 Set object = rtitem.EmbedObject _
     ( 1454 , "", arr(k))
before loop keep k=0
and in the loop keep k=K+1


Sub Initialize
     Dim session As New NotesSession
     Dim db As NotesDatabase
dim view as notesview
     Dim doc As NotesDocument
     Dim rtitem As NotesRichTextItem
     Dim object As NotesEmbeddedObject
     Dim notestime As New notesdatetime("")
     Dim notesdate As New notesdatetime("")
     notesdate.LocalTime = Date
     notestime.LocalTime = Time
     Set db = session.CurrentDatabase
set view=db.getview("yourViewName")
set doc=view.getfirstdocument
while not doc is nothing

Set rtitem = New NotesRichTextItem( doc, "Body" )
     Set doc.ProcessDate= notesdate
     Set object = rtitem.EmbedObject _
     ( 1454 , "", "\\xxxx\xxxxxr\xxxx\xxxxxx1STnotes.xls")
    ' doc.Form = "1st Shift Production Report"
     doc.Subjectproductions = "xx"
     doc.productionrpt = "xxxxxx 1st Shift"
     doc.shift = "1"
     doc.createddate = notesdate.LocalTime
     doc.createdtime = notestime.LocalTime
     Call doc.Save( True, True )
set doc=view.getnextdocument(doc)
wend
     'Set doc = New NotesDocument( db )
     
     
End Sub
0
 

Author Comment

by:sjmmajor
ID: 12015595
This is doing it at one time?  The file I am attaching is only updated on the shift so I don't want to change that document until their shift and then it would retain the last one.  So there would actually be 3 in the view at all times.
0
 

Author Comment

by:sjmmajor
ID: 12016646
I ended up using a view for each shift but I will keep all for future reference.  I am still using an agent which all your code really helped me see and understand the agents and script more.  Thanks so much for your time and effort.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

12 Experts available now in Live!

Get 1:1 Help Now