Dec 10 2005

Open a page from a document in a view

Tag: Lotus NotesAndrea Ercolino @ 00:00:36

Some documents with web bookmarks appear in a Notes view. How do you open a bookmarked page bypassing the opening of the correspondig Notes document?
Two solutions follow: one uses Notes magic, and the other the InViewEdit event.

Notes magic

  1. Create a Dummy form, used for doing nothing (it sounds weird but works)
  2. Dummy: for preventing document creation, it should have a field [SaveOptions]=0 (text /computed for display)
  3. Dummy: for preventing form opening, it shoud have a sentence Continue = False in the QueryOpen script
  4. View: for inhibiting the default behaviour, in the FormFormula object write “Dummy”
  5. View: put the formula @UrlOpen( Bookmark ) into the QueryOpenDocument formula

now, if you double click the Bookmark document, the page (just it) appears in a new window

(revised text from my own comment 12351627 at Experts-Exchange)

InViewEdit event

Something special happens if an editable column shows a value as an icon: The SAVE_REQUEST type of the InViewEdit event is triggered as soon as the user clicks on the icon.

Sub Inviewedit(Source As NotesUIView, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
' This view has one editable column, which is for display of an icon.

     ' Define constants for request types
     Const SAVE_REQUEST = 3

     ' Define variables
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Dim ws As New NotesUIWorkspace
     Dim caret As String

     ' Get the CaretNoteID - exit if it does not point at a document
     caret = Source.CaretNoteID
     If caret = "0" Then Exit Sub

     ' Get the current database and document
     Set db = Source.View.Parent
     Set doc = db.GetDocumentByID( caret )

     ' Select the request type
     Select Case Requesttype

     Case SAVE_REQUEST
          Dim w As New NotesUIWorkspace
          w.UrlOpen doc.URL( 0 )
          Continue = False

     End Select
End Sub

(revised text from my own comment 12738085 at Experts-Exchange)


Dec 09 2005

Put a web page in a string

Tag: Lotus NotesAndrea Ercolino @ 23:59:55

If your server is Win32, you could use the following function to put a page in a string. It’s based upon a service of the MSXML library, which installation is an easy task (and maybe it’s a service already running)

Function GetPage( url As String ) As String
     Dim objHttp As Variant
     Set objHttp = CreateObject( "Msxml2.ServerXMLHTTP" )
     Call objHttp.Open( "GET", url, False )
     Call objHttp.Send()
     If objHttp.status <> 200 Then
          GetPage = "FAILED (status: " & objHttp.status & ")"
     Else
          Dim contentType As String
          contentType = objHttp.getResponseHeader( "Content-Type" )
          If contentType = "text/html" Then
               GetPage = objHttp.responseText
          Else
               GetPage = "Not HTML (type: " & contentType & ")"
          End If
     End If
     Set objHttp = Nothing
End Function

(revised text from my own comment 12271511 at Experts-Exchange)


Dec 05 2005

Sort totals in categorized views

Tag: Lotus NotesAndrea Ercolino @ 23:25:01

Notes calculates totals for categorized views, but does not sort them.
So if you need it anyway, you have to

  1. navigate the categories in the non-sorted but categorized view (by means of the NotesViewEntry… classes)
  2. create a new document for each category with a field to record that total and a field to record that category
  3. add a non-categorized view for showing the new documents with a sorted column for the total field

Here is the LS code for an agent that implements 1- and 2-

Sub Initialize
     Dim s As New NotesSession
     Dim db As NotesDatabase
     Set db = s.CurrentDatabase
     Dim v As NotesView
     Set v = db.GetView( "ViewByCategories" ) ' use here the name of your categorized view
     Dim n As NotesViewNavigator
     Set n = v.CreateViewNav
     Dim e As NotesViewEntry
     Set e = n.GetFirst ' this should be the first category
     If e Is Nothing Then
          Print "empty view... exiting"
          Exit Sub
     End If

     Dim summary As NotesDocument
     Do While Not( e Is Nothing )
          Set summary = new NotesDocument( db ) ' create a new summary document
          summary.Form = "SummaryForCategory" ' use here the name of your form for the summaries
          ' set all the fields you need, for example
          Call summary.ReplaceItemValue( "Total1", e.ColumnValues( 1 ) )
          Call summary.Save( True, True ) ' save the summary

          Set e = n.GetNextCategory( e )
     Loop
End Sub

(revised text from my own comment 12349447 at Experts-Exchange)


Dec 05 2005

Compose in a new window

Tag: Lotus NotesAndrea Ercolino @ 23:24:12

To compose a document in a new window, make a button with the following formula:

@SetTargetFrame( “_blank” );
@Command( [Compose]; “a form” )

(revised text from my own comment 12095830 at Experts-Exchange)


Dec 05 2005

Keep current order

Tag: Lotus NotesAndrea Ercolino @ 23:21:22

SearchOrder=[1,2,3,4]
Indicate 1 to “Sort by relevance,” 2 to “Sort by date ascending,” 3 to “Sort by date descending.” The default is 1. SearchView also supports a SearchOrder value of 4 to “Keep current order,” which sorts the resulting set of documents in the order in which they appear in the view.

(from URL commands for searching for text, Notes Designer Help database)

Don’t let the “Keep current order” option mislead you. The resulting set is what comes after selecting the documents that match the search query (SearchOrder=1) and cutting out all the documents outside the range [Start, Start + Count - 1]. So, whatever the order in which they appear in the view, any page of documents is all messed up.

This is a bug that only shows up when searching views and paging the result set, i.e. almost always when searching views, i.e. almost always when searching. At any new page request, either with the same query or not, Notes conducts a brand new search, where the resulting set is sorted in a most-relevant-to-Notes way, if SearchOption=4 was specified. Then Notes extracts all the Count documents beginning from Start, and finally shows them in the order in which they appear in the view.

It could be said that “SearchOrder=4″ has a resulting-page scope, as opposed to a resulting-view scope.

(revised text from my own comment 12067686 at Experts-Exchange)


« Previous Page