Lapas

Saturday 10 April 2010

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.

No comments:

Post a Comment