Migration Issue - Retro-creation of parent document

We have recently rebuilt a database to add a new higher level of relationship.

Previously we used to have a collection of documents all at one level:

  • Document1 (form fNCI)

  • Document2 (form fNCI)

  • etc

In the new database, this is the structure:

  • Parent Document (form fNSO)

    • Child Document1 (form fNCI2)

    • Child Document2 (form fNCI2)

    • etc

Essentially form fNCI and fNCI2 are the same, except that form fNCI2 inherits field information from its parent fNSO.

What we’d like to be able to do is this:

  1. create/add new parent docs to the old records made using form fNCI (which will now need to become a response document to the new parent doc).

  2. Populate shared fields in Parent doc from those in the original fNCI form.

  3. Replace form fNCI with form fNCI2 on newly migrated documents.

I really have no idea how to begin - any suggestions very very welcome!

Cheers

Graham

Subject: Migration Issue - Retro-creation of parent document

Look into the MakeResponse method. You simply create the new documents, then call the MakeResponse to re-create the parent/child relationship you want.

Subject: RE: Migration Issue - Retro-creation of parent document

Thanks for your help.

This is what I propose to do - from the document I want to migrate:

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim thisDoc As NotesDocument

Dim targetOrder As NotesDocument

Set db = session.CurrentDatabase

Set view = db.GetView( “vMigrateOrders” )

Set targetOrder = view.GetLastDocument

Set thisDoc = workspace.CurrentDocument

'Create Order from this doc

Call workspace.ComposeDocument(“”,“”,“fOrder”)

Call doc.Save( True, True )

'Populate fields in Order from thisDoc then save

targetOrder.fieldname = thisDoc.fieldname2

'etc

Call thisDoc.Save( True, True )

'Make thisDoc a response to the last Order in the view

'Set form attribute so that it sits in views as a response, then save

Call thisNCI.MakeResponse(targetOrder)

thisNCI.Form = “Response”

Call thisNCI.Save( True, True )

'Change form from fOldForm to fNewForm

'Stuck here - is there a LotusScript method for switching the form used to view a document?

Does this look like it’ll work?

Subject: Not quite

Most of it looks correct, but in the bit

'Create Order from this doc

Call workspace.ComposeDocument(“”,“”,“fOrder”)

Call doc.Save( True, True )

where are you setting the composed document to doc. Shouldn’t this be more like

Set uidoc = workspace.ComposeDocument(“”,“”,“fOrder”)

Set doc = uidoc.Document

Call doc.Save( True, True )

or am I missing something?

Subject: RE: Not quite

Thanks - I’ll give your suggestion a try.To be honest, I’d got to the trial and error stage!

Subject: RE: Migration Issue - Retro-creation of parent document

OK - I aleady know this doesn’t work. As you’ve probably guessed, I’m new to scripting!

Any suggestions please…