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
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

624 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