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

x
?
Solved

how to transfer documents from another database in lotus notes 6.0

Posted on 2006-05-08
15
Medium Priority
?
454 Views
Last Modified: 2013-12-18
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
Comment
Question by:1902software
  • 5
  • 4
  • 4
  • +2
15 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16637167
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
 
LVL 13

Expert Comment

by:CRAK
ID: 16637309
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
 

Author Comment

by:1902software
ID: 16637329
no, its not manually copy & paste..actually i need some sample code. :)
0
Technology Partners: 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!

 

Author Comment

by:1902software
ID: 16637400
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
 
LVL 14

Assisted Solution

by:cezarF
cezarF earned 800 total points
ID: 16637548
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
 
LVL 13

Accepted Solution

by:
CRAK earned 1200 total points
ID: 16639090
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
 
LVL 18

Expert Comment

by:marilyng
ID: 16654886
Nicely done CRAK...
0
 
LVL 13

Expert Comment

by:CRAK
ID: 16655924
Thanks. I assume you are referring to the educational touch?
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16657285
Exactly..:)
0
 

Author Comment

by:1902software
ID: 16676976
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
 
LVL 18

Expert Comment

by:marilyng
ID: 16677739
You need to change the password, and contact email address, then.
0
 

Author Comment

by:1902software
ID: 16679234
Yes we already have. Anyway, we still have points to give. So does CRAK deserve it?
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16679288
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
 
LVL 13

Expert Comment

by:CRAK
ID: 16680336
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
 

Author Comment

by:1902software
ID: 16680625
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 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