1
votes

If using Domino Access View to access a database view as a REST call, is there anyway to pass view selection parameters as part of the URL query string, specifically to accept a date range? This is to limit results to certain criteria?

I have seen the 'keys' and 'keysmatch' params but this won't help with the range selection issue.

Suspecting no, but just wanted some expert feedback!

2

2 Answers

2
votes

You could easily write your own REST API on the Domino server and have it accept for example a date range.

I have examples of this in my presentation here: http://blog.texasswede.com/my-connect-2016-presentation-demo-database/

Here is the Lotusscript code for the server agent that makes up the REST call:

Use "Class.URL"
Use "Class.JSON"

Sub Initialize
    '*** Local Notes classes used in agent
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim thisdb As NotesDatabase
    Dim view As NotesView
    Dim col As NotesViewEntryCollection
    Dim entry As NotesViewEntry 
    Dim doc As NotesDocument
    '*** Custom classes
    Dim url As URLData
    Dim json As JSONData
    '*** Local variables to hold arguments passed from URL
    Dim startdate As String
    Dim enddate As String
    '*** Other local variables
    Dim jsontext As String 

    '*** Create new URLData object
    Set url = New URLData()
    '*** Create new JSONData object
    Set json = New JSONData()

    '*** Check start date and convert from ISO to US date format
    If url.IsValue("start") Then
        startdate = ISOtoUS(url.GetValue("start"))
    Else
        startdate = "01/01/1980"
    End If

    '*** Check end date and convert to US date format
    If url.IsValue("end") Then
        enddate = ISOtoUS(url.GetValue("end"))
    Else
        enddate = "12/31/2199"
    End If

    '*** Send MIME header to browser
    Print "content-type: application/json"
    jsontext = ""
    Set db = session.CurrentDatabase
    Set view = db.GetView("Events")
    Set col = view.AllEntries
    Set entry = col.GetFirstEntry()
    Do Until entry Is Nothing
        If CDat(entry.ColumnValues(0))>=CDat(startdate) Then
            If CDat(entry.ColumnValues(0))<=CDat(enddate) Then
                Call json.SetValue("id", CStr(entry.ColumnValues(5)))
                Call json.SetValue("title",CStr(entry.ColumnValues(3)))
                Call json.SetValue("start", Format$(CDat(entry.ColumnValues(7)),"mm/dd/yyyy hh:nn ampm"))
                Call json.SetValue("end", Format$(entry.ColumnValues(8),"mm/dd/yyyy hh:nn ampm"))
                Call json.SetValue("className","eventData eventData" + CStr(entry.ColumnValues(6)))
                Call json.NoStatus()
                '*** Make the entry editable (change date/time) 
                Call json.SetBoolean("editable", True)
            End If
        End If
        jsontext = jsontext + json.GetJSON() + "," + Chr$(13)
        Set entry = col.GetNextEntry(entry)
    Loop
    If Len(jsontext)>4 Then
        jsontext = Left$(jsontext,Len(jsontext)-2)
    End If
    Print "[ " + jsontext + " ]"
End Sub


%REM
    Function ISOtoUS
    Description: Convert ISO date to US date,
    e.g 2015-05-08 to 05/08/2015
%END REM
Function ISOtoUS(dateISO As String) As String
    Dim tmp As String
    ' 2015-02-03
    tmp = Mid$(dateISO,6,2) + "/"
    tmp = tmp + Mid$(dateISO,9,2) + "/"
    tmp = tmp + Left$(dateISO,4)
    ISOtoUS = tmp 
End Function

Notice that it is using two helper classes I wrote, you can find the code for them on my blog as well: http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/ and http://blog.texasswede.com/calling-a-notes-web-agent-from-another-server-using-jsonp/

1
votes

As far as I know this is not possible. You can use the query parameter to retrieve documents matching the search query you submit (which performs a domino ftsearch) .

More details can be found in the documentation here: View/folder entries GET