Solved

how to regularly copy specific data from one notes database to another

Posted on 2007-11-14
9
191 Views
Last Modified: 2013-12-18
I have one database that is used mainly for data entry, and another database that's a read only repository. Both databases have the same fields.   Once records in the entry database are approved by a supervisor, they are to be transferred to the read only repository.  I have a view that shows approved records. I'm looking to create a "send to repository" button that calls an agent. How should I go about programmatically transferring these approved records to another database?  

If possible, I'd like to be able to run a reconcilliation report to verify that all approved records transferred.  Much of the time, these recent data entries need to replace records that are in the repository ( they're updated).  

Thank you in advance.

Everett Johnson

0
Comment
Question by:everetjo
[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
  • 2
  • 2
  • +1
9 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 250 total points
ID: 20282452
If all the fields are identical, then you can use the copyallitems

here is something that can be used as an eample

Private Function createDocCopy(docWorkflowable As notesDocument,
docUserCopy As notesDocument, Byval dbName As String, Byval
keepSingleCopy
As Integer, controlFlag As Integer) As Integer
     On Error Goto createDocCopy_ErrorHandler

     Dim docCopy As notesDocument
     ...
     ' The following line gets executed if no copy ever existed
     ' In the debugger, docCopy is NOT Nothing
     Set docCopy = New notesDocument(dbOther)
     ...
     docWorkflowable.copyAllItems docCopy, True
     ...
     ' After the agent has executed, the copy exists in the second
database
     docCopy.save True, False
     ...

     Stop
     Set docUserCopy = docCopy
     ...
     Goto exitThisFunction

createDocCopy_ErrorHandler:
     ...
exitThisFunction:
End Function

I hope this helps !
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 250 total points
ID: 20285004
It sounds like sometimes the documents to be copied will REPLACE an existing repository document, and sometimes they will replace an existing one.

I'm also assuming each document is self-contained, i.e., no repsonse documents, no related doucments that have to be moved together, etc.


First, you need to gather the documents to be transfered.  I assume you want some administrative user to go into the approved records view, click the button, and EVERYTHING in that view should then be transferred.  The basic code for that loop is as follows:

Const repositoryServer = "name of server"
Const repositoryFile = "path\filename.nsf"
Dim repository As New Notesdatabase(repositoryServer , repositoryFile )
   'above does not create new database, just new object variable pointing to database
Dim ws as new notesUiWorkspace
Dim view as notesView, doc as notesDocument
Set view = ws.currentView.View
Set doc = view.getFirstDocument
Do Until doc Is Nothing
  doc.copyToDatabase repository
  doc.remove False
  Set doc = view.getFirstDocument
Loop

The above always copies the approved doc to the repository, never replacing anything existing. If you wanted t o replace something exitsing, you have to do two things:

1) Idnetify the document to be replaced
2) Replace it, which itself has two ways:
2a) delete the old document and copy in the new one (uses same code as scrip above)
2b) leave the existing document in place, but rpelace its content (uses a different call)

Here might be one way to do this. At the top of the code, you have:

Const repositoryServer = "name of server"
Const repositoryFile = "path\filename.nsf"
Const repositoryKeySearchView = "path\filename.nsf"
Const keyFieldName = "name of a field used to match new documents against old"
Dim repository As New Notesdatabase(repositoryServer , repositoryFile )
Dim repositoryView as NotesView
Set repositoryView = repository.getView(repositoryKeySearchView)
Dim ws as new notesUiWorkspace

And your loop becomes one of these:
Do Until doc Is Nothing
  repositoryView.getAllDocumentsByKey( doc.getItemValue(keyFieldName) , True).removeAll False
  doc.copyToDatabase repository
  doc.remove False
  Set doc = view.getFirstDocument
Loop

Do Until doc Is Nothing
  Dim oldVersion as notesDocument
  Set oldVersion = repositoryView.getDocumentByKey( doc.getItemValue(keyFieldName) , True).removeAll False
  If oldVersion Is Nothing Then
    doc.copyAllItems oldVersion , True 'note, any fields on old doc that are not on new doc will remain on old doc!
    oldVersion.Save True,True
  Else
    doc.copyToDatabase repository
  End If
  doc.remove False
  Set doc = view.getFirstDocument
Loop
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 20307081
Hello everetjo,

Probably no coding is required. I think it can be handled by defining the read-only database as an archive database, and enable archiving on the main database. Only approved documents should then be archived. Of course, this only works if the same form is used in both databases, because the document will be moved as is.

Regards,
   Sjef
0
Industry Leaders: 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 31

Expert Comment

by:qwaletee
ID: 20314800
Sjef,

Doesn't solve the second half of the problem (sometimes copy sometimes update).
0
 

Author Comment

by:everetjo
ID: 20316905
Thanks for the prompt responses.  I'll try these suggestions and let you know.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 20319027
I'll settle for half the points...

LOL
0
 

Author Comment

by:everetjo
ID: 20405864
still working on trying to implement this.  let you know soon.
0
 

Author Comment

by:everetjo
ID: 20552435
I had a problem with the database that had to be fixed before I could try this solution.  since I'm all caught up again, I'll try things during the week and get back.  thanks again for the great suggestions.
0
 

Author Comment

by:everetjo
ID: 20583847
I am using field modification code in my repository that will track changes to the fields ( e.g. field note was changed from " cookies are tasty" to " cookies taste better with ice cream"

I think that gwaletee's suggestion is the closest to what I'm looking for.

I'm thinking that I want my data to transfer to the repository in two ways:

if it's a new record ( doesn't exist in the repository) copy to repository
if it's a modification to existing record, replace the contents o the repository, don't delete the record.

thoughts ?

I take regular backups, but I feel that the modifiction code should allow me to track content changes better.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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