When you click a button (button1) in a form where an existing document (doc1) is displayed on the web, I want to be able:
-
to create a new document (doc2) which copies the exact contents of the currently displayed document (doc1);
-
to display and edit the newly created document (doc2); close the previous doc1.
-
by clicking another button (button2), submits and saves the newly created document (doc2) with the user changes; and changes the status of the first doc (doc1) and saves it too.
How I did it so far but failed:
-
On click of the button 1, @Command([EditDocument]) ----- this is doc1.
-
On click of button 2,
@Command([ToolsRunMacro]; “CopyDoc”);
@SetField(“LastUpdated”; @Today);
@Command([FileSave]); - saves doc2
@Command([FileCloseWindow])
I call a macro (lotuscript)- Copy Doc with the ff. code:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc, curdoc As NotesDocument
Dim newdoc As NotesDocument
Set db = session.CurrentDatabase
Set curdoc = session.DocumentContext (doc1)
Set doc = db.GetDocumentByUNID (curdoc.UniversalID) (hoping it will pick up the original field values of doc1 but didn't)
Set newdoc = db.CreateDocument
Call doc.CopyAllItems(newdoc, True) (copies NOT the original field values of doc1 but new values changed by the user)
newdoc.Status = "Closed"
Call newdoc.Save(True, False, False)
End Sub
I also tried doing it this way:
- On click of the button 1, I have the ff. code
@Command([EditDocument]); — refers to doc1
tempid := @DocumentUniqueID; — assigned temp variables
tempcountry := Country;
templastupdated := LastUpdated;
temppmemergencytype := PMEmergencyType;
@Command([CloseWindow]); ---- close doc1.
@Command([Compose]; “Assessment”); ---- create doc2
@SetField(“UID”; tempid); — retrieve the temp variables and set the field values
@SetField(“Country”; tempcountry);
@SetField(“DisplayCountry”; tempcountry);
@SetField(“LastUpdated”; templastupdated);
@SetField(“PMEmergencyType”; temppmemergencytype);
@Command([RefreshWindow])
Problem in the above code is that I get a new document (doc2) but it is blank and it does not show the field values from the doc1.
Thanks and appreciate in advance for any help.