« Classic Notes: How to communicate with IBM Connections from LotusScript wrapping IBM SBT with LS2J - Part 2 | Main| Just for the fun of it... here are some wordles for Lotusphere-abstracts since 2000 up to 2014 ... »

Classic Notes: How to communicate with IBM Connections from LotusScript wrapping IBM SBT with LS2J - Part 3

Tags: LotusScript Java Connections

This part 3 of 3 in the article series “Classic Notes: How to communicate with IBM Connections from LotusScript wrapping IBM SBT with LS2J”.

Read the others here:

Part 1

Part 2


This is the second subclass inherited from the superclass SBTHelperBase100.java. I don’t to much into details here yet, since I have only coded samples equal to the sbt.sample.app’s GetAllCommunitiesApp() sample. I did try to create an addMember-method, but have at present time a strange exception in the core SBT during this operation.

You will however see that this class is built on the same concept as for the SBTActivityStreamHelper100-class. It is now all about exposing exactly what you want to your LotusScript developers.

LotusScript finally - meet the classes:SBTHelper100 script library

I has been quite a journey down here! Coming here you hopefully have something you can run in Eclipse as stand-alone java applications, much similar to the sbt.sample.app-project samples.

The second main trick is to use LS2J - or - LotusScript to Java. For help on LS2J use the Domino Help;


Opening the agent classes:SBTHelper100 reveal that I have used classes here too, but now it is of course LotusScript classes. I simply love the concept of LotusScript classes, and whilst they arent nearly as powerful as java-classes, they still can make a nice touch in LotusScript!

First and foremost, we must tell the script library that we want to use LS2J


This is done via the UseLSX “*javacon” followed by the Use “classes:SBTJavaHelper100”.

As for the java-classes, the LotusScript classes also has the notion of superclasses and subclasses. The primary class is CConnectionsBase. The subclasses CConnectionsCommunityHelper and CConnectionsActivityStreamHelper are both inherit the superclass CConnectionsBase. Let’s have a look at the superclass;


At (1) I have the member variables for the Lotus Notes session and the database. In other words, the objects of this type has a built-in notion of a NotesSession and it’s parent NotesDatabase.

At (2) I have the LS2J-related variables, such as JavaSession, JavaClass and JavaObject. Similar to how you must first obtain a NotesSession to get a NotesDatabase, you have a similar “chain of command” in LS2J where you first must create a JavaSession object, then get the needed JavaClass-objects and finally get the JavaObject-objects themselves. You’ll see this in a while.

At (3) I have a NotesDatabase object and a couple of views to the Domino Directory (aka Name and Address book). Remember, I want to be able to just specify the source- and target names and use lookups into Domino Directory instead of being forced to use e-mail addresses which Connections like.

At (4) I have a NotesDatabase-object and a couple of views to my Connections Communities database. Remember, when posting to communities, I must have the uuid of the community. While SBT can grab the uuid of any public community, or any community that the userid is member of, it can’t seem to grab the uuid of other, restricted, communities. My database is just a dump of the SNCOMM.COMMUNITY table in the backend Connections DB/2 database. A powerful example on “if you can’t do it here, then do it there”-approach a programmer so often meet!

At (5) I have an error string and stack trace variable, which will contain the error and stack trace from backend java if something goes wrong. Believe me, you will use this!

The constructor-method New initializes the object;


Nothing special here. Note that the superclass initialize the m_javaSession variable.

You’ll see a bunch of support methods, and below I focus on the main methods. First out is GetUsersInternetEMailAddress;


This method accepts almost any kind of name (short name, e-mail, Notes name, our internal so-called universal name), and see if it can find the corresponding record in the Domino Directory.

At (1) I resolve the variable “@me” to the current username. This way I blend the LotusScript powers with the Connections’ usage of the @me-variable.

At (2) I do a search in the ($NamesFieldLookup)-view in the NAB. If not found there, I also try the user name view at (3).

At (4) I grab the internet address field if present and it contains something. Voilš - I have the internet address

Next method mentioned, is the GetCommunityUuid.


The concept of GetCommunityUuid is very similar to GetUsersInternetEMailAddress above, but now I accept a community name as input parameter and lookup the correspondig uuid. This is all possible because of the database integration I do in another project with Connections SNCOMM.COMMUNITY table.

By the way - I also asked this question on StackOverflow.org about how to get the uuid of any community by it’s name, but the only answer so far (from Paul Bastide, a very knowledgeable guy on SBT) indicated to use the seedlist. I am not that familiar with the nitty gritty details of Connections either, but got the understanding that the seedlist is used by external search engines indexing the content in Connections. Seemed like a overkill for my purpose )

A closer look at the subclass CConnectionsActivityStreamHelper

The subclass CConnectionsActivityStreamHelper inherits the superclass CConnectionsBase and thus have all variables and methods of the superclass.

Below you see the class-definition and the constructor (New) method. Remember, in LotusScript the superclass’ New will be called first, and thus we have our m_javaSession in place when this New-method is called afterwards (you see m_javaSession in play at (2)).


At (1) you see a subclass is made to inherit a superclass i LotusScript. Just beneat you see the member variable m_javaPostEntry (which isn’t used right now) and note how it is set as Private. This means that this variable will be local to this subclass only.

At (2) I create the JavaClass object m_javaClass. Note how I specify the class to use with “no/tine/sbt/SBTActivityStreamHelper100”. Since every class in Java most often is the same as a single java-file this correlates to the java library script file SBTActivityStreamHelper100.java, as shown below:


At (3) I instantiate the JavaObject m_javaObject, which also is a member variable of the superclass CConnectionsHelper. Note that the JavaObject is the actual object from the class - or one instance of it. This means that you can access any method that the class expose as public, and that is exactly what I have done with the postEntry-method.

At (4) you see some experimental code, where I try to create a postEntry method (remember the local m_javaPostEntry variable) with it’s parameters and all. If it all had worked, I would have had a type-safe object accepting only the correct parameters to the method. If you lookup the help for JavaObject it seems to have very powerful possibilities. Unfortunately I couldn’t get this to work at the time of this article. But that doesn’t stop me from using the JavaObject directly. More on that below!

What will the LotusScript-developer use and see?

Up til now we have been working with backend classes and configuration topics in order to be able to communicate with Connections.

As stated first, only two classes needs to be copied into in the target database, the classes:SBTHelper100 and helper classes:SBTJavaHelper100.

Below you see the complete code for a test-agent. Before diving into the code, you must ensure that the agent runs with elevated rights.


If you forget to do this, both the Notes client and the Domino server won’t run your code. The symptoms aren’t that obvious either, so just remember to do this

- Wooha, what about security!?, you say. Nothing is compromised here, as you as the signer of the agent has elevated rights on the Domino server and of course knows what you are doing Another approach is of course to make to back end agent which has been signed with an Notes id with elevated rights, and then use an ordinary low-security agent as a front end, triggering the backend agent with NotesAgent’s RunOnServer. you’ll see a sample on how to do this at the end of the article, as I also want to be able to run the test-agent below in the context of the Domino server.

Now, let’s see the complete agent code;


The code above is just an annotated version of the first screen shot in this article.

At (1) you see how I use the script library classes:SBTHelper100. If you have read the complete article, you now know that this is the LotusScript wrapper code around the backend java script library named classes:SBTJavaHelper100 which wraps the real SBT java code itself. The communication between LotusScript and Java is made possible via LS2J.

At (2) you see how I define and instantiate the CConnectionsActivityStreamHelper object. This code could also have been written like this …


… you like that way of writing code better. As soon as the object is called, the constructor method New is first called in the superclass CConnectionsBase , and then in the subclass CConnectionsActivityStreamHelper.

At (3) I just create a string telling me whether the agent runs in the context of the Notes client or in the context of the Domino server. This string is later used when posting

At (4) I check whether the connection to Connections went well in the construction phase of the object. If something is wrong, such as the user id, password or connections URL, you’ll see that in the error handling at (6)

At (5) I do the actual posting to the activity stream. The two last parameters are the source- and target “user” which can be either a person or a community depending of what you specify as the first parameter (“person” or “community”). I have explained in previous sections how I have distilled the abilities in my code so I can stuff the postEntry-method with names, e-mails, short names, and community names instead of the uuid’s which Connections will use in the end.

At (6) I check if everything went well, and if not I get the error message and java stack trace if it is available from the exception.

Launch the agent above in the context of the server

The code is simple and looks like this;


The trick is simply to use the NotesAgent class and at (1) get the first agent with an alias agnSample01. At (2) I run the agent on the server, and thus in the context of the server.

Remember that the database with this code must be placed on the server in the first place!


If you have followed me all the way, thank you for your patience! I have tried to compile all the necessary steps needed to be able to use LotusScript to communicate with Connections. Of course this code is very much in the works, and will of course evolve over time. My primary goal has been to “get something though” to Connections and thus use this project as a Proof of Concept. I am certain that this approach will make it considerably easier for our LotusScript developers, me included, to communicate with Connections.

I can hardly wait to get working with Embedded Experience - which I believe is one of the coolest technologies I’ve seen in a long time.

Hope you enjoyed the ride!

Proud Programmer!

PS! You find the code here.


Gravatar Image1 - Great series, Robert!

Could you pls open source this code on OpenNTF?

Post A Comment