 |
|
| Let's say that you for some reason have a form with an embedded view that lists a bunch of documents. You would like to mark one of the documents in the embedded view and get a grip of this document and do something with it. Sounds easy but could be a bit tricky! This is how I have solved it (with some help form the ). Step 1In the view that is embedded in the form, add the following formula code to "Target Frame (single click)": | @SetEnvironment( "eViewSelection"; @Text(@DocumentUniqueID)) |
What happens here is that an environment variable named 'eViewSelection' is set when clicking on a document in the view with the text value of the document unique id. In more detail this means that a row is added or updated in notes.ini that looks something like this: | $eViewSelection=00C2635582348362C125737F003C09AD |
Step 2When you somewhere else on the form need to get a hold of the document (to get a value from it or mail it as reference or something else), perhaps using lotusscript on a button, you can access it by first get the value of the environment variable that was set when clicking the document in the view and later on to use it. Here's an example: Sub Click(Source As Button) On Error Goto ErrorHandler Dim session As New NotesSession Dim db As NotesDatabase Dim selectedDocID As NotesDocument Dim selectedDocIDString As String
Set db = session.CurrentDatabase selectedDocIDString = session.GetEnvironmentString("$eViewSelection", False)
If(selectedDocIDString <> "") Then Set selectedDocID = db.GetDocumentByUNID(selectedDocIDString) Else Msgbox "You have to select a document!" Exit Sub End If
' ' Do something really cool with this document if that is possible ;-) '
' Set environment variable to empty string to be ready for next run Call session.SetEnvironmentVar("$eViewSelection", "" )
Exit Sub ErrorHandler: ' Log error Msgbox "An error occurred" Exit Sub End Sub |
|  |
| | Comments:
|
| | Comment posted 2008-09-18 21:58:08 by Juan Colmenares
Hi Niklas... After I put the @SetEnvironment formula in the Target Frame (single click) then the ebedded view appears completely blank when Im testing the form...do you know why that is happening? Thank you
|
|
| | Comment posted 2008-09-19 09:57:43 by
Hi Juan, Just so that I understand. When you click on a document in the embedded view in your form, the view becomes blank? Or is it blank at all times, from start when opening the document?
|
|
| | Comment posted 2008-10-06 12:07:52 by Mei Mei
Hi Niklas, I encountered the same issue as Juan Colmenares. When I opened the form that contains the embedded view, the view is blank. Did I missed something? Thank you,
|
|
| | Comment posted 2008-10-06 12:27:08 by
Hi Mei Mei, Strange! I can not see an obvious reason to why the embedded view is blank. I suppose you have created a form with an embedded view before successfully? The embedded view is displayed using Java Applet, i.e. in the embedded view properties on the first tab the 'Display'-option is set to 'Using Java Applet'. Maybe this has something to do with it? But it would be interesting to know if this is something that only happens for you on this example or in general when creating a form with an embedded view.
Please let us know how you progress with this! / Niklas
|
|
| | Comment posted 2008-10-07 02:34:21 by Mei Mei
Hi Niklas, Thanks for your response. The 'Display' option is set to 'Using Java Applet'. The embedded view is blank after adding in Step 1. FYI, I am also using Single Category view and have other embedded views on the same form and they are working well. Any suggestion is appreciated.
|
|
| | Comment posted 2009-02-09 22:36:39 by sushant likhar
Try this code for version 6 and above. Dim ws As New NotesUIWorkspace Dim uiview As NotesUIView Dim s As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Set uiview = ws.CurrentView Set db = s.CurrentDatabase Set doc = db.GetDocumentByID(uiview.CaretNoteID) Messagebox doc.GetItemValue("Transaction_Type")(0),, _ "Current document is ..."
|
|
| | Comment posted 2009-02-16 14:30:57 by
does this code work for all websites or just certain types ?
|
|
| | Comment posted 2009-03-12 17:19:53 by McAndrew
I have the same problem, tested by LN8.5, LN7.0.2 - is it possible tu public example notes db? Thank you for help.
|
|
| | Comment posted 2009-03-13 14:33:46 by
@McAndrew Sure, I can extract that functionality in an example database. Give me a couple of days. There's a lot going on right now.
And please remind me if I should forget
|
|
| | Comment posted 2009-06-10 12:42:26 by Nagendra
Niklas,
Thanks for the Great R&D on document selection in an embedded view. I am also experiencing the same blank embedden view error.
Do you have any idea how to handle the selected docs in one db and work on these selected docs in other db?
My issue:
I have two dbs (db1&db2). Im creating a creating document1 using a form1 in db1. In this document1, i will select a db2, and form2 in the db2. When I save this document, automatically a view2 will be created with the name as form2 & the view2 seletion formula as the form2. Now I want to get this view2 as embedded element in my document1. Now I will select the documents on this embedded view and work on it. Do you have any ideas on this? Please let me know if you need more informaiton on this - nagendra.pprasad@inbox.com
Thanks, NP
|
|
| | Comment posted 2009-06-29 12:43:59 by
I experience similar problems...
|
|
| | Comment posted 2009-08-22 06:49:33 by
Thanks for making things easier.
Robert
|
|
| | Comment posted 2009-12-05 17:15:11 by Gregg
The problem some folks are having is they are setting the @SettEnvironment line in the embeddedview's "Target Frame (single click)": on the form. It needs to go in the "Target Frame (single click)": of the view itself.
|
|