Tutorial :Lotus Notes - scripting the creation of design element


I have a Lotus Notes application which actually consists of a template with all the required forms, views and agents needed. It also requires some design elements (a custom form and a view for our own type of documents) from this template to be copied over to the mail template, so after the regular refresh all users have it.

The application works like this: the application database (derived from the template I provide) is created on the Domino server. An agent, running in this database, upon http request, creates a "custom" document in user's mail database.

Then, on the client side, the user can use our view to display this document.

Currently, the deployment procedure goes like this:

  1. Create a "master" application database out of our template.
  2. Fill some data, using the forms and views in that database (to configure how the application works)
  3. Copy the custom form and view to the mail template.
  4. Create our button (to launch our view and/or form) on the mail template.
  5. After the nightly database refresh, all users receive the custom form and the view in their mail database, and they can use the button to view our documents (if any).

Now, I want to easy the admin's work, and automate the copying of the custom form and the view, and also the creation of the button to the mail template.

Any idea how I can do this from a NotesScript, JavaScript, Java?


That sounds doable with DXL, and I think you can use both LotusScript and Java to accomplish it.

Something along the lines of this should do it in Java:

public class RenderDesign extends AgentBase {  public void NotesMain() {        try {           Session session = getSession();          AgentContext agentContext = session.getAgentContext();            DxlImporter myimporter = session.createDxlImporter();          try {              myimporter.setDesignImportOption(myimporter.DXLIMPORTOPTION_REPLACE_ELSE_CREATE);              myimporter.importDxl(this.getDxl(), agentContext.getCurrentDatabase());              }           catch (Exception e) {              System.out.println(this.getDxl());              System.out.println(myimporter.getLog());                      }        } catch(Exception e) {          e.printStackTrace();      }  }  

Then just construct a string with the DXL. Use Tools -> DXL Utilities -> Exporter (or Viewer) to inspect the design element you want to add or edit:

public String getDxl(String agentname, String replicaid) {      return "<?xml version='1.0' encoding='utf-8'?>"+              "<view name='(auto-view)'> "+/* ... */"</view>";  }  

Note that the DXL importer is anything but robust and error-tolerant: You can make the Developer client crash on input that is valid XML and conformant with the DTD. For example, trying to set fieldhint="" on a field. Keep this in mind while developing.


Try looking at these for ideas ---> http://www.openntf.org/projects/pmt.nsf/3f2929edba6ef2808625724c00585215/9fe3084cab2f38ad8625754600078af6!OpenDocument


To avoid some of the DXL known issues you can try to export & import in encoded binary format.


After looking at your situation a bit more closely, I think the easiest route would be to use template inheritance. So you would copy the elements from your custom template into the Mail template and make sure the elements are setup to inherit from your custom template.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »