Pregunta

I've got a notes database that keeps its audit information in lists in each document. Every time something we want to keep track of is changed we update list fields; When, Who, What, and value. I have a nifty button that sends me from the form I'm on to its audit form. It just copies over the audit fields to the audit form which displays the results.

Sub Click(Source As Button)
    Dim wk As New NotesUIWorkspace
    Dim s As New NotesSession
    Dim db As NotesDatabase
    Dim uidoc As NotesUIDocument
    Dim doc As NotesDocument
    Dim item As NotesItem
    Dim newDoc As NotesDocument

    Set db = s.CurrentDatabase  

    Set uidoc = wk.currentdocument
    Set doc = uidoc.Document

    Set newdoc = db.CreateDocument
    newdoc.form = "InvoiceAudit"
    Set item = doc.GetFirstItem("AuditWhen")
    Call Newdoc.CopyItem(item,"AuditWhen")
    Set item = doc.GetFirstItem("AuditWhat")
    Call Newdoc.CopyItem(item,"AuditWhat")
    Set item = doc.GetFirstItem("AuditWho")
    Call Newdoc.CopyItem(item,"AuditWho")
    Set item = doc.GetFirstItem("AuditValue")
    Call Newdoc.CopyItem(item,"AuditValue")
    NewDoc.DocID = doc.UniversalID
    Call wk.EditDocument(True,NewDoc)
End Sub

We don't ever want to save this form. It's only purpose is to display the auditing information kept in each field. I have the following server sided code to emulate this in xPages....

var db:NotesDatabase = session.getCurrentDatabase();
var newDoc:NotesDocument = db.createDocument();
var doc:NotesDocument = currentDocument.getDocument(true);
var item:NotesItem;

doc.replaceitemvalue("Form","InvoiceAudit");
item = doc.getFirstItem("AuditWhen");
newDoc.CopyItem(item);
item = doc.getFirstItem("AuditWho");
newDoc.CopyItem(item);
item = doc.getFirstItem("AuditWhat");
newDoc.CopyItem(item);
item = doc.getFirstItem("AuditValue");
newDoc.CopyItem(item);

but for the life of me, I can't find something that emulates the wk.editdocument function....

¿Fue útil?

Solución

You don't need to copy design patterns from LotusScript. In your case you need to open the same document but with different form.

So the easiest thing is to make hotspot, that opens current document in another XPage (for audit form).

To open it in another window/tab, use target property set to _blank

Otros consejos

The problem here is that you first have to save the document (at the end of your SSJS code). Then you are able to compute the URL you have to open, e.g.

context.redirectToPage("doc.xsp?action=editDocument&documentId=" + newDoc.getUniversalID()

Another way could be: you store the temporary values in scoped variables, open the blank document xpage and prefill the fields with the values from the scoped variables. This way is elegant as you don't have to remove the temporary document created with the first method in the case you want to dismiss it. Keep in mind: please do not store Notes objects (such as the newDoc object) in a scoped variable as it is not ensured that it will be there after loading another page...

you can display the audit information in a dialogbox, by preparing a hidden panel with those information, and a button to show this panel in dialog

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top