Opening an existing document from LotusScript agent

i there,

I have an agent which is triggered from a button in a form. What it does is, given a UNID, find a document with matching UNID. If found, launch it, else create new document and pass the UNID given to a field of the new document. Hence get the UNID of this new document and launch it. Here’s a litle code that I’ve writen. All is working well, except for finding a way to launch the found document in Notes Client.

Sub Initialize

 Set ss = New NotesSession

 Set db = ss.CurrentDatabase

 

 Dim view As notesview

 Dim doc, DERdoc As notesdocument

 Set doc = ss.DocumentContext

 If doc Is Nothing Then Exit Sub

'**********************************************

 Set view = db.getview("DERByID")

 Set DERdoc = view.GetDocumentByKey(doc.DocUniqueID(0),False)

 theid = doc.DocUniqueID(0)

 If DERdoc Is Nothing Then

      Set DERdoc = db.CreateDocument

      DERdoc.Form = "DER"

      DERdoc.ParentID = doc.DocUniqueID(0)

      DERdoc.SuspCauseOfFailure = doc.SuspCauseOfFailure(0)

      DERdoc.EquipmentType = doc.EquipmentType(0)

      DERdoc.Region = doc.Region(0)

      DERdoc.Station = doc.Station(0)

      DERdoc.Substation = doc.Substation(0)

      DERdoc.LocationOfFault = doc.LocationOfFault(0)

      DERdoc.EquipFailDt = doc.OutageRptDt(0)

      

      Call DERdoc.ComputeWithForm( True, False )

      Call DERdoc.Save(True, False)

      Call view.Refresh

      Set DERdoc = view.GetDocumentByKey(doc.DocUniqueID(0),False)

 End If

 Print "[" + DERdoc.DocURL(0) + "]"

End Sub

The print statement opened the document in the browser alright, but it doesn’t do it in client, but i just cannot get a way to open it in the Notes client, and im running out of idea. I was thinking of programming it separately for client using formula/command, BUT after i use the dblookup to find the document, i need to refresh the lookup view in order to ‘register’ the document found, otherwise the newly created document will not be found when i want to open it. What is the equivalent of lotusscript ‘ViewRefresh’ in the formula/command ? Getting rather desperate now…

cheers to anybody there who’s will to help…reallyappreciate it.

Subject: Opening an existing document from LotusScript agent

Have a look at the NotesUIWorkspace.EditDocument call in the Designer Help, you can open Notes docs using that

Cheers

Peter