Get data from DB2 via LotusScript

I have recently made an Lotus Notes Database, where i needed to get some information from DB2.
I this case i also had the issue that only the server could connect to the DB2.

I made an agent that call another agent with the runOnServer method.
Then you can select a document, start a agent that calls a agent on a server, connect to db2, and update the selected document.

Here is an example on how to call db2 in a agent.

Option Public
Option Explicit
Uselsx “NLSXLC”

Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim agent As NotesAgent
Set db = session.CurrentDatabase
Set agent = session.CurrentAgent
Dim doc As NotesDocument
Dim LC_S As New LCSession
Dim LC_Conn As New LCConnection( “DB2”)
Dim LC_FldLst As New LCFieldList(1)
Dim LC_Field As New LCField( LCTYPE_TEXT, 1)
Dim strLCMsg As String
Dim strLCErrorTxt As String
Dim lLCMsgCode As Long
Dim nStatus As Integer
Dim lCount As Long
Dim strSelectStatement As String
Dim strKundenr As String
Dim lTotal As Long
Dim ngl As String
Dim x As string

‘Get doc
Set doc = db.GetDocumentByID(agent.ParameterDocID)

LC_Conn.Userid = “SETUP_ALIAS_USER”
LC_Conn.Password = “SETUP_ALIAS_PASSWORD”
LC_Conn.Database = “SETUP_ALIAS_DB2”
LC_Conn.Disconnect
LC_S.ClearStatus
LC_Conn.Connect
Print “Connect called”

strSelectStatement = “SELECT * FROM DB.Table”
lCount = LC_Conn.Execute( strSelectStatement, LC_FldLst)
Print “Execute Select Statment called”

If lCount <> 0 Then
lCount = LC_Conn.Fetch( LC_FldLst, 1, 1)
‘Select what you want to get from the select
Set LC_Field = LC_FldLst.GetField( 1)
While ( lCount > 0 ) And ( LC_S.Status = LCSUCCESS )
x = x + LC_Field.text( 0)
lCount = LC_Conn.Fetch( LC_FldLst, 1, 1)
lTotal = lTotal + 1

Wend
End If
LC_Conn.Disconnect
LC_S.ClearStatus
‘ex: write to doc
Call doc.Replaceitemvalue(“field”,x)
Call doc.save(True, False)
End Sub

Posted in Lotus, Tip | Tagged , , , , , | Comments Off on Get data from DB2 via LotusScript

#Dannotes – The Danish Lotus Group Conference

Last week I attended the 47.th Dannotes Conference (the Danish Lotus User Group).

It was 2 days full of Admin/Dev stuff. Ulrich Krause, Paul Withers and Dave Hay was guest speakers on the Admin/Dev track. A lot of good stuff was shown to us.

Guys from IBM was also there to tell about the future, and of course Social was also on the agenda.

Key points from the speakers:

IBM Worklight, new thing within the smartphone segment

Check out the slidedeck from Ulrich Krause. A lot of good Xpages info

Xpages-beyond the basic – http://www.slideshare.net/eknori/dan-notes052012-beyondthebasics

Checkout Firebug extension from OpenNTF. Debug Xpages in notes client, like with firebug in firefox browser.

Ready, Set, Go! How IBM Lotus Domino XPages Became Mobile – http://www.slideshare.net/paulswithers1/dannotes-xpages-mobile-controls

In the xsp.properties file, xsp.theme.mobile.pageprefix=mobile.
Then all xpages starting with mobile, gets all the right stuff automaticly loaded, and you don’t need to do anything

Check out – http://Notesin9.com

Combine languages.
Ex in a label on a xpage. You can combine ordinary text with code Ex: “text” $(javascript:@dbtitle)
You can use # or $ and then (javascript: in text to compute either Client side og server side javascript)

All in all it was nice to see all the familier faces again, and i’am sure many off us will be back next time.

P.s. Thanks to the Dannotes board for making this conference a success.

Posted in Lotus | Tagged | Comments Off on #Dannotes – The Danish Lotus Group Conference

Battery time on your laptop

Informative Diagram showing battery life on your laptop.

Posted in Tip | Tagged , | Comments Off on Battery time on your laptop

Maybe wet Formula 1 GP comming up…

Look at the weather forecast for Friday, Satarday and Sunday. It confirms that its almost certain to rain in Malaysia.

It seems its all geared up for a hot humid and a wet race in Malaysia.

Its mayby time to get super wet Pirelli tyres.

This is very exciting for all us F1 Fans.

Lets hope for at good and exiting race sunday.

Posted in F1 | Comments Off on Maybe wet Formula 1 GP comming up…

Print in the background .. Part 2

Last week I asked if anyone knew about a trick to print a Notes Document i the background. I got a lot of feedback, and thank you to the community for that.

There was some good proposals, but i couldn’t use any off them, because i have to use the Notes Form, and print that. But read my old blog entry, if you want some input on how to do it with pdf/iText.

I found my own solution, and here it is:

I have a java program that has to print a notesdocument via a key.

I have the java program make a small txt/xml file, and put in in a specified place. Then the java program opens a url, that opens a Notesdatabase. notes://…..

Then the notes database opens the txt file, and reads it, opens the document, prints if, and closes both the document, and the database again.

I call the code in database postopen, because the I can print the document just by openning a url.

I know its note a pretty solution, and you have to have a workstation/server allocated for the print.

But it works.

Posted in Lotus, Tip | Comments Off on Print in the background .. Part 2

We are so close… Formula 1 is about to start

6 Airguns – 6 World Champions…..

Posted in F1 | Tagged | Comments Off on We are so close… Formula 1 is about to start

Can you print a document in a background agent ?

I have searched almost everywhere, and i haven’t found any smart tricks to print a document in a background agent. If its possible at all.

I know all print functions is in the UI classes. But have anybody found a workaround. Thee i would like to know !

Comments are welcome

Posted in Lotus | Tagged , | Comments Off on Can you print a document in a background agent ?

IdeaJam post. Server should be able to retrieve mail from another server

I posted an idea on IdeaJam.

I want a server to be able to retrieve mail from another server, instead of it always are receiving.

But it seams that I am the only one that don’t want to do Ninja tricks to get the mail routing working when sending mail from outside the firewall.

My Idea was:

I you have a server outside the firewall, and you only have a open port from inside and out, we can not get mail to work from outside. Because the server wants to deliver mail to the inside server, and it can not do that.

I would like to be able to specify (like with replication) witch server that handles the mail, when 2 domino servers sends mail to another.

So the outside server just puts its mail in mail.box a then do nothing. And another server check the mail.box, and if there is mail, it gets them, and sends them on

You can find the post here:

http://ideajam.net/IdeaJam/P/ij.nsf/0/7F5F3F463A7E4AD04A2579B400487A4B

Would like to hear comments on this subject. Is I way off ?

Posted in Lotus | Tagged , , , | Comments Off on IdeaJam post. Server should be able to retrieve mail from another server

We have something you really have to see. And touch

This is the text Apple has written in the invitation for the event at march 7.

Many have speculated about what i means. I think that the phrase: ‘you really have to see’ means the new Apple TV. And the phrase: ‘And thouch’ refers to the Ipad 3.

But will look forward to the show.

Posted in Apple | Tagged , | Comments Off on We have something you really have to see. And touch

Yellow is the new Black

Stole this picture from Mat Newman’s blog. Hope its okay. But it can not be said to often.

Posted in Lotus | Tagged | Comments Off on Yellow is the new Black