Solved

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

Posted on 2007-11-14
9
186 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
  • 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
 
LVL 31

Expert Comment

by:qwaletee
ID: 20314800
Sjef,

Doesn't solve the second half of the problem (sometimes copy sometimes update).
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

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

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

13 Experts available now in Live!

Get 1:1 Help Now