Ben Langhinrichs

Photograph of Ben Langhinrichs

E-mail address - Ben Langhinrichs

Recent posts

Thu 29 Apr 2021

Archive a Notes DB off-line w/ Field data and active content

Tue 20 Apr 2021

Archive a Notes DB off-line in 4 easy steps

Thu 18 Mar 2021

Preservation of all the tiny details

May, 2021
02 03 04 05 06 07 08
09 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Search the weblog

Genii Weblog

RPC - Empowering the server while retrieving to the client

Thu 27 Aug 2020, 08:17 PM

by Ben Langhinrichs
Inline JPEG image
In my earlier post, Quick primer on JSON-RPC, I promised to post videos showing some features of our new Exciton Boost, due out next week. A few days ago, I followed this up with a first at the REST API in REST Revisited. It is time to demonstrate the RPC API, but I want to start with a little context.
In the modern world, both server and client are very powerful. Processing power is abundant, but there are still decisions to be made about where processing should happen. These decisions may be based on security, on related data available, on where you want business logic to live, and many other reasons. In this simple demo, I should how you can use powerful RPC methods on data as it is being pulled out of Domino, even without changing the data on Domino. So, the logic is done there, but the results are passed to the client. You can use similar logic to change the data in Domino, or to change data as it is added to Domino, but we'll look at use cases for both in another demo.
HTML and JavaScript used in the demo. I hardcoded the UNID in this, but the logic would work the exact same way of I had walked a view and read a document from there. Note that there is no explicit authentication code because this lives in the same database and the session handles that.
<!DOCTYPE html>
const genHTM =   { jsonrpc: "2.0",  
                   method: "rtc.generateHTML",
                   params: [ "Everything", "XHTML", "CSSBorders=yes Generation=fragment " ],
                   id: 1
const glossary = { jsonrpc: "2.0",
                   method: "rtc.linkMatching",
                   params: [ "", "MedXref.nsf", "Medical Glossary", "Term", "Definition",
                             "Fieldname=Definition Hotspot=Mouseover Style=Highlight " ]
const links =    { jsonrpc: "2.0",
                   method: "rtc.linkMatching",
                   params: [ "", "MedXref.nsf", "MedLinks", "Term", "Link", "SingleMatch='Yes' " ]
function doIt(num) {
switch(num) {
  case 1:
    var data = [genHTM];
  case 2:
    var data = [glossary, genHTM];
  case 3:
    var data = [glossary, links, genHTM];
    var data = [genHTM];
fetch('https://localhost/Health.nsf/api/boost/documents/E755B7DA837C1FFF852585D1004A25DC/rpc?save=false', {
  method: 'POST', 
  mode: 'same-origin',
  cache: 'no-cache',
  headers: {
    'Content-Type': 'application/json',
  body: JSON.stringify(data),
.then(response => response.json())
.then(data => {
 document.getElementById("demo").innerHTML = data[0].result;
.catch((error) => {
  console.error('Error:', error);
<button type="button" style="border-radius: 6px;" onClick="doIt(1);">Get the document as is</button><br>
<button type="button" style="border-radius: 6px;" onClick="doIt(2);">Get the document and apply the glossary on the way out</button><br>
<button type="button" style="border-radius: 6px;" onClick="doIt(3);">Get the document and apply the glossary and link matcher on the way out</button><br>
<p id="demo"></p>

Copyright 2020 Genii Software Ltd.

What has been said:

No documents found

Have your say:

Name *:
e-mail addresses will not be displayed on this site
Comment *:

<HTML is not allowed>
Linking: Add links as {{http://xxx|title}}, and they will be activated once approved
Blocked? Unable to post a comment? Please read this for a possible explanation...