Right, you gonna have to trust me - I have searched for the answer…I’m a script newbie. I have err…“created” (or borrowed) an agent to create a duplicate document…It seems to work quite nicely, if you are interested try http://www.snug.nl/home/newsletter.nsf/0/e6171d315a5c2380c1256e21007628fd?OpenDocument
BUT - now I want the duplicate document to Open…I can’t beleive I’m posting this I must have missed something SO obvious…Any ideas?
Heres the script, which creates a new document with a new @Unique thingie, then saves it BUT doesn’t OPEN it? Any ideas?
Sub Click(Source As Button)
Dim uiws As New NotesUIWorkspace
Dim session As New NotesSession
Dim currentDB As NotesDatabase
Dim profileView As NotesView
Dim profileDoc As NotesDocument
Dim currentDoc As NotesDocument
Dim duplicateDoc As NotesDocument
Set currentDB = session.CurrentDatabase
Set currentDoc = uiws.CurrentDocument.Document
Set duplicateDoc = New NotesDocument(currentDB)
Call currentDoc.CopyAllItems(duplicateDoc)
Dim eval As Variant
unique = Evaluate("@Unique", doc)
Call duplicateDoc.ReplaceItemValue("OurRef", unique)
'Call duplicateDoc.ReplaceItemValue("Stage", " ")
'Call duplicateDoc.ReplaceItemValue("ReqCmpDte", 0)
'Call duplicateDoc.ReplaceItemValue("Dateneed", Now + 7)
Call duplicateDoc.Save(True, True)
End Sub
Subject: LS Duplicate/Open Document - Silly Question any ideas???
the answer you seek is in the uiworkspace documentation in Notes help.
You are 1 line away from nirvana.
find thy ‘piece’
Subject: RE: LS Duplicate/Open Document - Silly Question any ideas???
is that the edit document thingie? How do I feed it ‘duplicateDoc’?
Subject: RE: LS Duplicate/Open Document - Silly Question any ideas???
Set uiDoc = workspace.EditDocument(True, duplicateDoc)
or
Call workspace.EditDocument(True, duplicateDoc)
True assumes that you want to open the document for editing. Use False if you just want the user to stare in awe at the wonder of your newly-minted document. (Sorry, I got kind of carried away after the nirvana thing…)
Subject: RE: LS Duplicate/Open Document - Silly Question any ideas???
Oh mighty gods of coding, methinks we are nearly there! But somehow the current doc remains in foreground! Maybe he can go away or we can switch to the newly created one (as well as having it as a tab)…The code is working as an action inside a form you see…
Subject: RE: LS Duplicate/Open Document - Silly Question any ideas???
READ MY FRIEND READ!!!
uidoc.close
before opening the new doc.
Subject: RE: LS Duplicate/Open Document - Silly Question any ideas???
uidoc.close gives the error’variant does not contain an object.I also tried currentDoc.close(True)
which gives the error
‘Illegal Use of Property’ or
or Call currentDoc.close(True) which gives the error
‘Illegal Use Of Property’
Heres the code again:-
Sub Click(Source As Button)
Dim uiws As New NotesUIWorkspace
Dim session As New NotesSession
Dim currentDB As NotesDatabase
Dim profileView As NotesView
Dim profileDoc As NotesDocument
Dim currentDoc As NotesDocument
Dim duplicateDoc As NotesDocument
Set currentDB = session.CurrentDatabase
Set currentDoc = uiws.CurrentDocument.Document
Set duplicateDoc = New NotesDocument(currentDB)
Call currentDoc.CopyAllItems(duplicateDoc)
Dim eval As Variant
unique = Evaluate("@Unique", doc)
Call duplicateDoc.ReplaceItemValue("OurRef", unique)
'Call duplicateDoc.ReplaceItemValue("Stage", " ")
'Call duplicateDoc.ReplaceItemValue("ReqCmpDte", 0)
'Call duplicateDoc.ReplaceItemValue("Dateneed", Now + 7)
Call duplicateDoc.Save(True, True)
Dim workspace As NotesUIWorkspace
Call currentDoc.close(True)
'uidoc.Close
Set uiDoc2 = workspace.EditDocument(True, duplicateDoc)
End Sub
Subject: RE: LS Duplicate/Open Document - Silly Question any ideas???
GOT IT - HERES THE CODE:-Sub Click(Source As Button)
Dim uiws As New NotesUIWorkspace
Dim session As New NotesSession
Dim currentDB As NotesDatabase
Dim profileView As NotesView
Dim profileDoc As NotesDocument
Dim currentDoc As NotesDocument
Dim duplicateDoc As NotesDocument
Set currentDB = session.CurrentDatabase
Set currentDoc = uiws.CurrentDocument.Document
Set duplicateDoc = New NotesDocument(currentDB)
Call currentDoc.CopyAllItems(duplicateDoc)
Dim eval As Variant
unique = Evaluate("@Unique", doc)
Call duplicateDoc.ReplaceItemValue("OurRef", unique)
'Call duplicateDoc.ReplaceItemValue("Stage", " ")
'Call duplicateDoc.ReplaceItemValue("ReqCmpDte", 0)
'Call duplicateDoc.ReplaceItemValue("Dateneed", Now + 7)
Call duplicateDoc.Save(True, True)
Dim uidoc1 As notesuidocument
Set uidoc1 = uiws.currentdocument
uidoc1.Close
Dim uidoc As NotesUIDocument
Set uiDoc = uiws.EditDocument(True, duplicateDoc)
End Sub