Lapas

Saturday 10 April 2010

Embedded view from External DB

1. Standard method replacing replicaid in form using dxl.
2. Advanced method using forms, frameset and embedded editor.

You have 2 databases, form1 (db1) and view1 (db2) which should be displayed. How to make it without composite applications and DXL tools?

Simply:
1. Create frameset1 in db1 with 2 frames, Top and Bottom. Make top frame 1 Pixel height.
2. Create empty form in db1, let's call it Form1Embed, set it to open in frameset1 Top frame.
3. Create form or page in db2, let's call it Form2Embed. Add embedded view1 to this form. Then add simple code in postopen:
dim ws as new notesuiworkspace
dim uidoc as notesuidocument
set uidoc=ws.currentdocument
'// fill some field with universal id of uidoc.document, then set single category from this field for view1
What this code do? the uidoc we get is parent document (form1).

3. Embed Form1Embed in form1 through embedded editor.
4. In frameset1 Bottom frame compute db2 path and our created element Form2Embed (that Form2Embed could be opened)

Now what happeps when you open form1?
1. form1 is loaded
2. Embedded editor loaded for form1embed, lotus opens this form in frameset1 top frame, which is not visible. Then computes Bottom frame with our form2embed from db2, which on load gets form1 document and uses it unid as single category key.


Lotusscript External DB calls

Sometimes, it is required to call functions from other related databases and then we have to choose copy libraries or try to call using parameters, so that libraries stay where they belongs to.
At least we have 3 possible call methods to access script from other LN database.

1. Calling agent with parameterDocID, where we could pass 4 bytes of data (note id length FFFFFFFF). Traditionally noteid of profile document or other document to process is passed. For more flexibility, can be used bit masks if agent works with UI and has access to context.
Main problem for this method is restrictions to passing parameters and for agents contains large libraries each time agent is loaded, script libraries are loaded again and again and no cached.

2. Second method is calling dialogbox in external database, by creating document in that db. Then we can pass parameters with no document save, use lotus cache (form cached) and access external lotusscript. Main problem is to reopen document after processing if needed, so that code should be splitted in 2 dbs, call function will handle return data and that we normally could not hide that dialog if we need if we want to return data.

3. Third method is the trick (some type of mutation of second method) found is that each document or UI element where external functions could be called is enclosed in frameset with 1 pixel top frame. Then form should be setup to open in frameset second frame. Visually document opens as always and no UI difference visible. Top frame is used to call external function. How to call?
3.1 simple method. In external database create form, create postopen event on event start you can access context uidoc using notesuiworkspace.currentdocument. No params could be passed in this case. But this method uses cash, which creatly boosts performance. To call form use notesuiworkspace.composedocument in top frame.
3.2 advanced method. use the same technique as in 3.1, but no post open event, only cache source document, for later use. Then create on form at least 2 editable fields: 1 for initial focus, 2 for function call. in second field write code in entering event. How to pass parameters? in caller db script. like in 3.1, but now we need returning uidoc to pass parameters. Use like set uidoc=ws.composedocument. Now use uidoc.document to write parameters in opened doc, after finished, just use uidoc.GotoField(second field). This method is like calling extenal agents with more flexibility and cache.