Trying to open a document in another DB with a button

Hi. I have read a few similar questions about this in other posts, but none of them seem to be exactly the same scenario as this.

Assuming that I don’t have a useful first sorted column in any views in the target database, here’s what I’m trying to do.

A document based on Form A, that the user is creating in database A, has a button on it that creates a document based on Form B, in database B. When you click the button, it copies some fields from the form B-based document back into the form A-based document (such as record #, status, etc). I also have it copy the UNID of form B.

Now, I want another button on the document created from Form A that will allow me to open the Form B document that was created. It’s easy with formula language, if you have a sorted column, but I don’t.

Can I use the UNID that I copy over, and GetDocumentbyUNID to do this? Or do I still need a first sorted column? If it is possible, can someone help me code this?

Thanks!

Subject: Give @Urlopen(“notes://…”) a shot

Hi Ben,why not try urlopen with the Notes protocol. Besides beeing used for attacks against notes clients it can be put to good use there. Memento:

notes:/// for local dbs.

notes://server/db.nsf/viewname/key_or_unid?open

Give it a shot and let me know how it worked for you.

:wink: stw

Subject: RE: Give @Urlopen(“notes://…”) a shot

Thanks stw, but I want it to open in the client, not a browser.

Is it really this difficult to open a document in another database if you don’t have a usuable view? Even with Lotusscript? All I want to do is be able to open a doc by it’s UNID, but without having a view with the first sorted column being UNID.

Thanks!

Subject: RE: Give @Urlopen(“notes://…”) a shot

With LotusScript, you can use the Open method to get any database, use GetDocumentByUNID to get a document in it without having to go through a view, then EditDocument to open it in the client.

Subject: RE: Give @Urlopen(“notes://…”) a shot

Ben,

notes:// is a client protocol! It will not open your browser. The “browser” registered for the “notes://” is the Notes client.

Try it!

:wink: stw

Subject: notesdatabase.getdocumentbyunid

Subject: RE: notesdatabase.getdocumentbyunid

Bruce, thanks. Can you help me with the code? I’m new to Lotusscript, but what I’m trying doesn’t appear to be working. I have a hidden field called URUnid that contains the UNID of the document I am trying to open.

Dim s As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim db As NotesDatabase

Dim doc As NotesDocument

Set uidoc = ws.currentdocument

Set db = s.GetDatabase(“myserver” , “myDB”)

db.GetDocumentByUNID(uidoc.FieldGetText(“URUnid”))

Subject: RE: notesdatabase.getdocumentbyunid

last line should be:

set doc = db.getdocmentbyunid(uidoc.FieldGetText(“URUnid”))

then you can open it into the ui with:

ws.editdocument false, doc

HTH!

Subject: RE: notesdatabase.getdocumentbyunid

Worked like a charm. THANKS!!!

Subject: 's allright