@transform

Have been using this for the first time today. It is a very powerful function – I will be using this more often in the future.

Today I used it to remove all role names from a list:
 
        @Trim( @Transform( authors; "name"; @If( @begins( name;"[" );"";name )) );

Check the Notes Designer help for more examples

Designer.exe hack

When supporting a user, you might need the Designer client. Luckily, you don’t have to install it – it’s allready there. To enable, just goto the Notes program folder and create a file called ‘designer.exe’ (use notepad to create a new file, then rename). Restart Notes, and you have the Designer icons in the bookmark bar… 🙂

Environ( “Temp” )

Environ( "Temp" ) returns the windows temp path. You can use the ‘SET’ command from a cmd window in windows to view all the envionment variables, e.g.
        HOMEDRIVE=C:
        HOMEPATH=Documents and SettingsJakob Majkilde
        LOGONSERVER=\MAJKILDE-LAPTOP
        NUMBER_OF_PROCESSORS=2
        OS=Windows_NT

Controlling scheduled agents

When you activate a scheduled agent, it will run right away. To prevent this, you can include the following code:

        If session.IsOnServer Then ‘don’t check if agent is activated by the user
                If Not session.CurrentAgent.HasRunSinceModified Then Print "Agent activated – will run as scheduled" : End
        End If

Then the agent will only run when scheduled – and not when activated.

If you want to run the agent right away, on the server, you can use a ‘launcher’ agent – something like this (complete code in the Developer Toolbox database):

Dim session As New NotesSession
Dim db As NotesDatabase
Dim s As String
       
Set db = session.CurrentDatabase

‘array class is included in the cls.system script library
‘can be found in any database from majkilde.com
Dim agentlist As New Array( Null )
       
Forall a In db.Agents
        s = a.name
        If Instr( s, "|" ) > 0 Then
                s = Strleft( s, "|" )
        End If
        Call agentlist.add( s )
End Forall

If agentlist.count = 0 Then Msgbox "No scheduled agents found in database", 64, "Error" : End

Dim ws As New NotesUIWorkspace
Dim n As New NotesName( db.Server )
s = ws.Prompt( PROMPT_OKCANCELLIST, "Select agent", "Select a agent to run on " & Ucase( n.Common ), "", agentlist.sort )

If s "" Then
        Dim agent As NotesAgent
        Set agent = db.GetAgent( s )
        Call agent.RunOnServer( )
        Msgbox "Done. See log for details", 64, "OK"
End If
       

BUG: Can’t read from the document if a frame is named ‘NotesView’

I have a form with one field (called ‘value’) and one button with this formula: @prompt([ok];"Value";value);
Then I create a frameset with 2 frames:
– Frame 1 is called ‘NotesView’ and contains something (a view?)
– Frame 2 contains my sample form
If I type a value in the field and click the button, it will display an empty box – and not the value?!?
If I rename the frameset, the button works – or if I just use the form without the frameset….

Download sample database

Passthru html on a form

To display html on a document, you must enable the "Render pass through HTML in Notes" option on the form properties
You can use html:

  • On the form
  • In Computet Text
  • In RichText field

But not in regular summary fields.

Notice that the html is only rendered when the document is loaded (like: computet when composed)

Working with WebServices

Creating a WebService consumer. This can be done in many ways, depending of the platform:

Notes 8: Builtin functionality – Create a new Lotus Script library and click the ‘Import WSDL’ button below

Notes 7: Use Stubby to create a Java agent. Also check this error page. If your WSDL file is version 1.2 you can try downgrading the file (download, edit and remove all the version 1.2 stuff), then use Stubby

Notes 7 and Notes 8:
Java can be a problem. It’s platform independent, but only runs in specific releases of Notes. You can create 2 agents – one for each release?
Or use LotusScript with the MSSOAP.SoapClient:

Set WshShell = CreateObject(“WScript.Shell”)
Set WshSysEnv = WshShell.Environment(“SYSTEM”)
strVersionNumber = WshShell.RegRead(“HKLMSoftwareMicrosoftWindows NTCurrentVersionCurrentVersion”)
If strVersionNumber = “5.1” Then
Objname = “MSSOAP.SoapClient”
Elseif strVersionNumber = “5.0” Then
Objname = “MSSOAP.SoapClient30”
Else
Msgbox “Your Operating System is not Windows XP or Windows 2000, this demo will not run.”
Exit Function
End If
Set SoapObj = CreateObject(objname)
Call SoapObj.mssoapinit (wsdl) ”Initialize connection to the WSDL file and get WSDL structure

(You can find this code in my (danish) sample WebService consumer & provider database)

Unfortunately this will only run on XP. The MSSOAP.SoapClient is not supported on Vista. Instead you can use the Msxml2.ServerXMLHTTP.3.0. With this you are down to the basic’s – you must create the XML/SOAP yourself, and send it with a HTTP POST request to the server. I used the Altova XMLSpy to create the SOAP request and to test the response data. You just import the WSDL file and Altova does the rest. Great tool – and they have a 30 day free trial version.

The final code could look like this (well, almost – there is a bug in the code below. I just receive an error message in the response text. Will keep you posted when I find the solution)

Dim http As Variant
Set http = CreateObject(“Msxml2.ServerXMLHTTP.3.0”)

Dim xmlStr As String
xmlStr = {} & Chr( 13 ) & Chr( 10 )
xmlStr = xmlStr & {http://schemas.xmlsoap.org/soap/envelope/” xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/“>

http://schemas.xmlsoap.org/soap/encoding/“>
TEST


}

Call http.Open( “POST”, “http://www.notesnet.dk/majkilde/ws.nsf/number?wsdl“, False )
Call http.setRequestHeader( “Content-Type”, “text/xml; charset=UTF-8” )

Call http.send( (xmlStr) )
Print http.responseText