Using native Notes API's - LotusScript example

 

Please refer to the document describing using the OnTime Group Calendar API (here after API) using Notes native API's before reading this document (see Using the OnTime Group Calendar API using Notes native APIs (over NRPC)).

Option Public
Option Declare


Sub Initialize
   'declarations
   Dim session As New NotesSession
   Dim noteid As String
   Dim request As String
   Dim response As String
   Dim dbApi As NotesDatabase
   Dim agentApi As NotesAgent
   Dim docApi As NotesDocument
   Dim item As NotesItem
   
   'create request
   request = |{"Main": {"ApplVer": "0.0.1", "ApplID": "Web2011", "APIVer": 2}}|
   
   'get API database, agent and document
   Set dbApi = New NotesDatabase("Solace/Krynn", "ontime/ontimegcapi.nsf")
   Set docApi = New NotesDocument(dbApi)
   Set agentApi = dbApi.GetAgent("ApiNotes")
   
   'set items
   Dim v(4) As String
   v(0) = "[ReadAll]"
   v(1) = "[Developer]"
   v(2) = dbApi.Server
   v(3) = session.Effectiveusername
   Set item = docApi.Replaceitemvalue("_Authors", v)
   item.Isauthors = True
   item.Isreaders = True
   Call docApi.ReplaceItemValue("$Request_0", request)
   Call docApi.Sign()
   Call docApi.Save(True, false)
   
   'get note id
   noteid = docApi.Noteid
   Delete docApi
   
   'call agent
   Call agentApi.Runonserver(noteid)
   
   'fetch API document
   Set docApi = dbApi.Getdocumentbyid(noteid)
   
   'get response
   Dim i As Integer
   While docApi.Hasitem("$Response_" & i)
      'append
      response = response & docApi.GetItemValue("$Response_" & i)(0)
      
      'increment
      i = i + 1
   Wend
   
   'show (JSON) response
   Print response
End Sub

 

Tuesday, 16 December 2014 Posted in Development