• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • Last Modified:

how to transfer documents from another database in lotus notes 6.0

Im a beginner in lotus notes..

I have two database: the HR dbase en Central dbase:

i have list of employee name in HR dbase. and if the employees were hired i can already copy the documents in the HR dbase.
my problem is at the view in the HR dbase, when i choose 3 documents and start to copy it to the Central dbase..
it will only copy the 1st document 3times and the remaining two will not.

can any one help me make a simple program on how to transfer documents from another database..
thanks!
0
1902software
Asked:
1902software
  • 5
  • 4
  • 4
  • +2
2 Solutions
 
Steve KnightIT ConsultancyCommented:
If you are doing this manually with copy & paste maybe you have three documents highlighted but not actually selected.  Try pressing space bar while each is highlighted which will put a small tick next to them in the selection bar or clicking the selection bar next to the document in the view then do Edit | copy then paste them into the other db.

If it isn't this the destination database could be not showing the documents in it's view or firing some code when a document is pasted which is stopping it.  Check File | Database | Properties and check the no. of documents in the db before and after the paste.

Steve
0
 
CRAKCommented:
I'm guessing here.....
Sounds like you're using code (lotusscript?) to do the job. Probably using a documentcollection.
Somewhere in there you check if a document belongs to "hired" personnel or not. It's that last bit that may contain a bug, like a missing "GetNextDocument", or a misused index in "GetNthDocument".
But I could well be miles off!

If there is code involved, could you please post it here, so we can see what's wrong?
0
 
1902softwareAuthor Commented:
no, its not manually copy & paste..actually i need some sample code. :)
0
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.

 
1902softwareAuthor Commented:
yes,im using lotusscript..

here is my code.. is used a button for it.

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace      
      Dim vwApplicantList As NotesView
      Dim session As New NotesSession
      Dim dbCentral As NotesDatabase
      Dim docUnpro As NotesDocument
      Dim docApplicant As NotesDocument
      Dim docEmpInfo As NotesDocument
      Dim docCenEmpInfo As NotesDocument
      Dim item As NotesItem
      Dim SERVERNAME As String
      Dim CENTRAL_DB As String
      
      
      'Get the selected document "the unprocessed document"      
      Set docUnpro = Session.CurrentDatabase.UnprocessedDocuments.GetFirstDocument      
      
      Set vwApplicantList = session.CurrentDatabase.GetView("vwApplicantListHid")
      
      If Not(docUnpro Is Nothing) Then
            If docUnpro.AppStatus(0) = "Hired" Then
                  'Get applicant form
                  Set docApplicant = vwApplicantList.GetDocumentByKey(docUnpro.Name(0))
                  
                  'Get Central Database
                  Dim uidbCur As NotesUIDatabase
                  Dim dbCur As NotesDatabase
                  Dim view As NotesView
                  Dim docCfg As NotesDocument
                  
                  Set uidbCur = ws.GetCurrentDatabase
                  Set dbCur = uidbCur.Database
                  Set view = dbCur.GetView( "vwSetUp" )
                  Set docCfg = view.GetFirstDocument
                  
                  SERVERNAME = docCfg.DBServer(0)
                  CENTRAL_DB = docCfg.FileCentral(0)
                  
                  Set dbCentral = session.GetDatabase(SERVERNAME, CENTRAL_DB, False)
                  
                  If dbCentral Is Nothing Then
                        Msgbox "Unable to find Central Database." + Chr(10) + "There might be an error in the database configuration & set up.   " , 16 , "Fatal Error"
                        Exit Sub
                  End If
                  
                  If dbCentral.isopen Then
                        Dim bResult As Boolean
                        Dim docType As NotesDocument
                        Set docType = session.CurrentDatabase.CreateDocument
                        bResult = ws.DialogBox( "(frmEmpType)",True,True,True, , , , "HR/Recruitment DB", docType, False, False )
                        
                        'Open application form of selected applicant                        
                        Set docCenEmpInfo = dbCentral.CreateDocument
                        'Copy all items from the selected document to the created document
                        Forall arrayItem In docApplicant.Items
                              Set item = arrayItem
                              Call docCenEmpInfo.CopyItem(item, "")
                        End Forall                        
                        'Modify its form name to "frmEmpInfo" then save it
                        docCenEmpInfo.Form = "frmEmpInfo"
                        docCenEmpInfo.NetName = Trim(docApplicant.FirstName(0)) + " " + Trim(docApplicant.LastName(0))
                        docCenEmpInfo.EmpStatus = docType.Type(0)
                        docCenEmpInfo.FlexTimeSched = Cdat("08:00:00")
                        docCenEmpInfo.DateOfEffect = Cdat(docCenEmpInfo.Created)
                        
                        IDNUM = Evaluate("@Unique+@Right(@Unique;4)")
                        
                        docCenEmpInfo.LogIDNum = Cstr(IDNUM(0))
                        Call docCenEmpInfo.Save(True, True)
                        
                        Msgbox "Personal information pertaining to " + docUnpro.Name(0) + " was successfully forwarded.", 64 , "Operation Successfull"
                        Call SetForward(docUnpro)
                        ws.ViewRefresh
                        
                  Else
                        'Database not found
                        Msgbox "Central database was not found.", 16, "Fatal Error"
                  End If
            Else
                  Msgbox "The candidate you selected has not passed the recruitment process yet.", 48 , "Operation Cancelled"
                  Exit Sub
            End If
            
      Else            
            Msgbox "Please select an application status document to forward.", 48 , "Operation Cancelled"
            Exit Sub
      End If      
End Sub

Sub SetForward(docStatus As NotesDocument)
      docStatus.ForwardToCentral = "1"
      Call docStatus.Save(True,True)
End Sub

what i want is for example to save the 3 documents w/c i selected from the view of HR database copy it to the Central database.
i guess i miss some looping but i don't actually know where to put it and a incrementation to select for the next doucment.
0
 
cezarFCommented:
in addition to crak's comment, you need to use something like this

dim dc as NotesDocumentCollection
dim doc as NotesDocument

set dc = db.UnprocessedDocuments
set doc = dc.GetFirstDocument
while Not doc Is Nothing
   'you code here
   ...
   ...
   set doc = dc.GetNextDocument(doc)
wend

0
 
CRAKCommented:
I can't test this for you but it either works or it will at least offer you some direction. I have added some remarks in capitals!
Replace the Sub Click with following:

Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace    
      Dim vwApplicantList As NotesView
      Dim session As New NotesSession
      Dim dbCentral As NotesDatabase
      Dim docUnproColl As NotesDocumentCollection ' NEW
      Dim docUnpro As NotesDocument
      Dim docApplicant As NotesDocument
      Dim docEmpInfo As NotesDocument
      Dim docCenEmpInfo As NotesDocument
      Dim item As NotesItem
      Dim SERVERNAME As String
      Dim CENTRAL_DB As String
      
      ' <Get Central Database - MOVED>
      Dim uidbCur As NotesUIDatabase
      Dim dbCur As NotesDatabase
      Dim view As NotesView
      Dim docCfg As NotesDocument
      
      Set uidbCur = ws.GetCurrentDatabase
      Set dbCur = uidbCur.Database
      Set view = dbCur.GetView( "vwSetUp" )
      Set docCfg = view.GetFirstDocument
      
      SERVERNAME = docCfg.DBServer(0)
      CENTRAL_DB = docCfg.FileCentral(0)
      
      Set dbCentral = session.GetDatabase(SERVERNAME, CENTRAL_DB, False)
      
      If dbCentral Is Nothing Then
            Msgbox "Unable to find Central Database." + Chr(10) + "There might be an error in the database configuration & set up.   " , 16 , "Fatal Error"
            Exit Sub
      End If
      ' </Get Central Database - MOVED>
      
      Set vwApplicantList = session.CurrentDatabase.GetView("vwApplicantListHid") ' MOVED
      
      Set docUnproColl = Session.CurrentDatabase.UnprocessedDocuments ' NEW
      If docUnproColl.Count >= 1 Then ' NEW
            
            'Get the FIRST selected document "the unprocessed document"    
            Set docUnpro = docUnproColl.GetFirstDocument ' ALTERED
            
            'If Not(docUnpro Is Nothing) Then ' REPLACED
            Do While Not (docUnpro Is Nothing) ' REPLACEMENT
                  If docUnpro.AppStatus(0) = "Hired" Then
               'Get applicant form
                        Set docApplicant = vwApplicantList.GetDocumentByKey(docUnpro.Name(0))
                        
                        If dbCentral.isopen Then
                              Dim bResult As Boolean
                              Dim docType As NotesDocument
                              Set docType = session.CurrentDatabase.CreateDocument
                              bResult = ws.DialogBox( "(frmEmpType)",True,True,True, , , , "HR/Recruitment DB", docType, False, False )
                              
                              'Open application form of selected applicant                    
                              Set docCenEmpInfo = dbCentral.CreateDocument
                              'Copy all items from the selected document to the created document
                              Forall arrayItem In docApplicant.Items
                                    Set item = arrayItem
                                    Call docCenEmpInfo.CopyItem(item, "")
                              End Forall                    
                              'Modify its form name to "frmEmpInfo" then save it
                              docCenEmpInfo.Form = "frmEmpInfo"
                              docCenEmpInfo.NetName = Trim(docApplicant.FirstName(0)) + " " + Trim(docApplicant.LastName(0))
                              docCenEmpInfo.EmpStatus = docType.Type(0)
                              docCenEmpInfo.FlexTimeSched = Cdat("08:00:00")
                              docCenEmpInfo.DateOfEffect = Cdat(docCenEmpInfo.Created)
                              
                              IDNUM = Evaluate("@Unique+@Right(@Unique;4)")
                              
                              docCenEmpInfo.LogIDNum = Cstr(IDNUM(0))
                              Call docCenEmpInfo.Save(True, True)
                              
                              Msgbox "Personal information pertaining to " + docUnpro.Name(0) + " was successfully forwarded.", 64 , "Operation Successfull"
                              Call SetForward(docUnpro)
                              
                        Else
                              'Database not found
                              Msgbox "Central database was not found.", 16, "Fatal Error"
                        End If
                  Else
                        Msgbox "The candidate you selected has not passed the recruitment process yet.", 48 , "Operation Cancelled"
                        Exit Sub
                  End If
                  
                  Set docUnpro = docUnproColl.GetNextDocument(docUnpro) ' REPLACEMENT (with "GetFirstDocument")
                  Loop  ' REPLACEMENT (with "do while")
            
            ws.ViewRefresh ' MOVED
            
      Else          
            Msgbox "Please select an application status document to forward.", 48 , "Operation Cancelled"
            Exit Sub
      End If    
End Sub
0
 
marilyngCommented:
Nicely done CRAK...
0
 
CRAKCommented:
Thanks. I assume you are referring to the educational touch?
0
 
marilyngCommented:
Exactly..:)
0
 
1902softwareAuthor Commented:
sorry about this guys, but this is an unauthorized entry. this account is sort of an 'official' office account and this not from a current office employee.

but to be fair to those who have posted solutions, I decided to award the points. Only problem is that I can't tell which is correct since I'm not sitting with the problem. So how about a vote to whom I will give the points.
0
 
marilyngCommented:
You need to change the password, and contact email address, then.
0
 
1902softwareAuthor Commented:
Yes we already have. Anyway, we still have points to give. So does CRAK deserve it?
0
 
marilyngCommented:
Cezar's was the first correct answer, but because the user didn't know script, would not have any idea on how to implement the suggestion.  CRAK's is the most complete answer, in my opinion.
0
 
CRAKCommented:
I'm too late to point out the "split" option or tell you to choose the (for you) most helpfull answer, but I see you've already worked that out.
Thanks for the points.

Still, I'm convinced that there must be a way to get this working!
The button is clearly triggered by a user. If the code was stored in an agent, it could stillbe triggered by a user if you want, it could run on the server on the signer's id or on behalf of another user. Could that offer a way out: a button launching an agent that runs as if it was triggered by someone else?
0
 
1902softwareAuthor Commented:
welcome crak. like I said, this entry shouldn't be here in the first place. But it's only fair to award the points. I'm not familiar with the problem so I don't think this should go on.

thanks guys
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

  • 5
  • 4
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now