Strange XPage, Unexpected runtime error

I’m going to start a post that I will update regular when I get strange errors that can be hard to find the solution for. Feel free to post a comment or use the contact form to send me your strange errors and a solution or how to debug the problem.

One of the best tools for debugging is to use the Log File reader found on OpenNTF, another good tool also on OpenNTF is the Debug toolbar

But now to the problems and the possible solutions.

Error while executing JavaScript action expression
Script interpreter error Interpret exception

javax.faces.FacesException: Error while executing JavaScript action expression

My script worked fine the first time I clicked on a button on the form. but the second time the same code ran I got this error Interpret exception, the problem was that I had an undeclared SSJS variable that caused the problem. Putting a var before the variable fixed the problem

Argument for ‘importPackage’ must be a package

You are using an SSJS package and is calling a java library and have written the name within quotes.

i.e importPackage(“com.xpagedeveloper”) but you should write importPackage(com.xpagedeveloper)

Events like onclick and partial refreshed is not working at all

Check if you have loaded any external javascript libraries like JQuery or Select2 the problem is probably AMD loaders that is in collision with Dojo. There is two different solutions I know of,

  1. Add some Pre or a post code that disable the AMD Loader, check out this great XSnippet @ OpentNTF
    https://openntf.org/XSnippets.nsf/snippet.xsp?id=hack-to-use-jquery-amd-widgets-and-dojo-together
  2. Or you can go into the Javascript library and remove the amd loader
    https://xomino.com/2015/06/02/select2-v4-needs-amd-fixing-in-domino-r9-xpages/

Clicks gone wild on your XPage

This is a problem I wrote about many years ago and it can be found here
onClick event is trigged where ever I click


This are the first three weird XPage errors but I will continue to add entries here that can help you and me because I can’t count the number of times I’m looking for a problem and I find my own blog with a solution 😉 Also check out my learning XPages page with lots of links

XPage crash with an strange null pointer error
I have done a writeup of the error in a separate post
NullPointerException: Argument error: One or more parameters are null

Debugging SAML setups in HCL Domino

Debug parameters

If SAML doesn’t work you will probably get Bad SAML Request [/names.nsf?SAMLLogin] in the Domino server console. The first thing you need to do is to add some debug parameters to Domino, the easiest way is to write them on the domino console but you can add the directly into notes.ini or using the configuration document in the Name & adressbook.

set configuration DEBUG_SAML=31

set config WEBAUTH_VERBOSE_TRACE=1

When settings have been enabled you will see a lot more information on the domino console and with in this you will find clues what could be wrong with you SAML setup.
Set the debug parameters to 0 to turn them off

HCL article about debug parameters

Session provider id

The first thing I check is what is written in the Service provider ID field against what is written on the provider side in ADFS, Okta, Azure or some other SSO provider. This information must be 100% the same so http vs https will brake it or a trailing slash.

SP Certificate

Another thing to check if you get strange problems with creating the SP certificate, is to always set your self as full administrator before creating the certificate. Why you might ask, well this is because the action will run code on the server to add the new certificate into the server id and without maximum rights you might run into problems when creating the certificate.

Export SP Certificate for encrypted SAML Requests

If the Idp site config uses encryption on the SAML requests you need to export the SP certificate and place it either in the Domino html folder in the server or add it to a database and use the redirect url functionality on a website configuration or send it to the Idp Administrator.

Office 365 / Azure requires HCL Domino 10 or newer

Connecting to Office 365 / Azure, If you have a Domino server prior to version 10 and want to connect this to Azure Enterprise applications using SAML that will not work, trust me I have tried.
You need at least Domino 10 and the new design of the IDP database with the option AuthnRequest SAML 2.0 compatible.

Multiple SAML logins gives problems

Another interesting findings of mine when implementing SSO Login for customers applications was that one of the sides in Azure or Domino doesn’t keep track of multiple SAML Logins, this show it self as when multiple logins is started only one login response will be returned. I.e if you have embedded multiple Domino iframes on a single webpage they might break due to this, you need to add some thing so only one login request is handled at one time.

Update: Domino 12.02 have support for multiple SAML certificates. Thanks Anders for the info

Setting up SAML with Okta as Idp for HCL Domino

Next Implementation is Okta you might run into problems decrypting the SAML data and get one of these errors if you have enabled the extended debug above.

SECCheckAndParseSAMLResponse> VerifyResponseSignature : The encrypted data has been modified or the wrong key was used to decrypt it
SECCheckAndParseSAMLResponse> VerifyAssertionSignature : The encrypted data has been modified or the wrong key was used to decrypt it
SECCheckAndParseSAMLResponse> Signature verification check failed : Could not verify cryptographic signature
SECCheckAndParseSAMLResponse> Exiting : The encrypted data has been modified or the wrong key was used to decrypt it

And you go in to the federation metadata xml file that you have downloaded from Okta. and check the certificate and everything looks ok and you wounder what is wrong isn’t Domino and Okta compatible with each other. Yes, they are well you need to be using HCL Domino 10 and above besides that there is a problem in the xml file, so open up the xml file that Okta has provided check each line in the certificate section and you will see that it’s ended with CRLF so the solution is to remove all CRLF with in the X509Certificate section of the XML file and save it and after that do the setup.

Multiple certificates in the Federationmetadata.xml file

Update from the community, if the metadata xml file contains multiple certificates Domino will use the last one so if the file contains multiple certs make sure that HCL Domino picks up the correct one otherwise you will get “The encrypted data has been modified or the wrong key was used to decrypt it” error.
Thanks for the info Jeffrey Redding

Getting a login loop when a user login

If you get a login loop when a user is trying to login then there is possibly a domain issue on you LTPA token cookie or that you or your Idp is ending up on the wrong protocol http/https and that is restricting cookies.

This is some of my SSO SAML findings connected to HCL Domino comment below if you have found some quirky thing when you have done setups.

Time Synk problems will give you a BAD SAML REQUEST

Time synk is very important to get the SAML login requests to run smoothly, without an accurate time they will fail anf give error messages like the one below.
SECCheckAndParseSAMLResponse> Exiting : Single Sign-On token has a creation time in the future. Single Sign-On servers may need to have clocks synchronized.
SECCheckAndParseSAMLResponse failed with error: Single Sign-On token has a creation time in the future. Single Sign-On servers may need to have clocks synchronized.
Error in SAML response – Single Sign-On token has a creation time in the future. Single Sign-On servers may need to have clocks synchronized.

SAML login / authentication no redirect

in Domino 12 users is redirected to the root or default specified url all the time.
so internal resource linking doesn’t work. Samesite cookie is what is causing this post explains how to fix it Login problems using SAML Domino 12

As you might understood by now, I can keep going with this due to the amount implementations of SSO I’ve done for clients both in their environment and against our Saas solution QNova Suite.

Create a random letter in Excel

I know that this is quite simple in Lotusscript, but some days I needed to create some kind of random string for a excel import and I thought let’s share this someone else might need this too or I might need this in the future and then I have it stored in my secondary archive my blogg 😉

=IF(RANDBETWEEN(1;9)>RANDBETWEEN(1;9);CHAR(RANDBETWEEN(65;90));IF(RANDBETWEEN(1;9)>RANDBETWEEN(1;9);CHAR(RANDBETWEEN(49;57));IF(RANDBETWEEN(1;9)>RANDBETWEEN(1;9);CHAR(RANDBETWEEN(97;122));CHAR(RANDBETWEEN(35;49)))))

This will create a random character , if you need a 8 letter string copy and paste this string with a and sign & between the formula eight times. I use this for simple password creation, Import keys.

Another of my excel functions I use alot is XLookup to get values from other sheets great to use when you have data from multiple sources. Checkout how to use it here

Hope this will help you, if you have some great Excel formulas post them in the comments.

Disable the first run off Lotusscript And Java agents after save

If you ever created some Notes/Domino agents and seen that everytime you save them a first run is scheduled outside or ordinary schedule. This can easily be avoided. Just add this code to the top of your agent

Dim s As New NotesSession
Dim a As notesagent
Set a=s.Currentagent
If a.Hasrunsincemodified=False Then Exit sub

This will make the agent to skip it’s first run, easy way stop the Lotusscript agent of running at odd hours and perhaps sending extra emails that confuses your users. You can ofcourse implement the same functionality in an Java agent.

If you want to run the same code inside a java agent then the code looks like this

try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
         if(agentContext.getCurrentAgent().getLastRun()==null){
        	 System.out.println("Not runned before");
         }else{
        	 System.out.println("Has runned");
         }

          // (Your code goes here)

      } catch(Exception e) {
          e.printStackTrace();
       }

Domino cookies needs to be secure and have samesite

The first thing is that Domino authentication cookies needs to be secured so you can’t hijack the content. This can be performed using the httponly and secure attributes.

Secondly we might need a way to add the samesite attribute to the cookies if we get problems with the new settings in Chrome. The same site settings is to block third party cookies that is used for advertising but in Domino this could give you problems if your applications is bouncing between domains. How to achieve this.

Server setting, no the Domino server doesn’t have this setting.
Vote for the Same site ideas on Domino ideas, UPDATE 2022 your votes made a difference this is now in Domino 12

Javascript, no that isn’t an option because the settings added removes control from javascript.

But using XPages we have no problem reading and set the cookies again with the correct attributes.

I’ve added this to the after page load event, you need to add this code for all Domino Related cookies that your setup use. Like LTPAToken, SessionID or DomAuthSessId

var c:javax.servlet.http.Cookie = cookie.get("DomAuthSessId")
var response=facesContext.getExternalContext().getResponse();
if(c){
if(c.getSecure()==false){

response.addHeader("Set-Cookie","DomAuthSessId="+c.getValue()+"; Path=/; Secure; HttpOnly; SameSite=None");
}
}

This changes the cookies after you have done a login but it will not help if the cookies is removed when you do a login.

Update to infinite scrolling snippet

Ferry did write a great snippet to get infinite scrolling in views posted on openntf xsnippets but lately I found that this had stopped working on some server versions. So I did some changes to get this to work on all versions

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
 
  <!-- make sure 'add rows' component is hidden -->
  <style>
    .infiniteScroll{display:none;}
  </style>
   
  <!-- add a class for the 'add rows component'  -->
  <xe:pagerAddRows id="pagerAddRows1"
    for="#{javascript:compositeData.repeatId}"
    styleClass="infiniteScroll">
  </xe:pagerAddRows>
 
   
  <!-- small script to check if we need to auto-click the 'add rows' button -->
  <xp:scriptBlock id="scriptBlock1">
    <xp:this.value><![CDATA[$(window).scroll(function(){
    if($(window).scrollTop() == $(document).height() - $(window).height()) {
      if($(".infiniteScroll ul li span").length!=0){
         $(".infiniteScroll ul li span")[0].click();
      }
      if($(".infiniteScroll ul li a").length!=0){
       $(".infiniteScroll ul li a")[0].click();
     }
   }
});]]></xp:this.value>
  </xp:scriptBlock>
</xp:view>

The changes is in the script block where I added a check if we find the span or the a tagg and if that we do a click on the first element found. This is because I didn’t get it to work using JQuerys ordinary click function.

Domino Data transfer between servers a different way

Domino has several ways of sending data or documents between servers the most common ways are as you all know replication. In another environments you might want to use an webservice.

But in domino there is several more ways to send data between servers, yes you can create a webservice but that isn’t that advanced, yes you can create an Rest service lots of work with the over head. You can send an email with an embedded form in it, how should you secure that.

Then you could actually run code on another server in an agent using Java or Lotusscript. By adding the server in to an trusted server list, nice. With compression and encryption added this is quite interesting. But there is a big but, the servers communicating needs to be in the same nab otherwise the communication fails 🙁

You might say what about cross certification, well this only works for replication not server to server code execution. But wait there is a way and this is how you make this work even if the servers are in different nabs and different certificates and it’s quite simple.

  1. Cross certify the server you want to communicate with both ways
  2. Add Server 1 in Server 2:s trusted server list
  3. Create a Person document on server 1 with server 2:s public certificate
  4. Create a Person document on Server 2 with server 1:s public certificate
  5. Add the server to the ACL on server 2

Now communication works in both ways I guess that you can change the server person with a user or perhaps add a user in the same way and run as the user. But the big thing is that you need the server you are callings public cert in the callers nab. If not you will get this on the server console.
server error your public key was not found in the domino directory

Teamviewer meeting integration in HCL Notes

Before the summer a customer approached me and asked if it was possible to integrate Teamviewer:s meeting function into the Notes calendar, so I created this solution for them. Check out the recording below.

Posting to Watson Workspace could have been the next article

But IBM will not continue to develop and announced that they will discontinue this platform, hope you didn’t invest to much in this platform.
IBM announcement
http://www-01.ibm.com/common/ssi/ShowDoc.wss?docURL=/common/ssi/rep_ca/4/877/ENUSZP19-0044/index.html&lang=en&request_locale=en

Some words from the community

http://oliverbusse.notesx.net/hp.nsf/blogpost.xsp?documentId=2F36

http://domino.elfworld.org/the-rumors-about-the-death-of-ibm-watson-workspace-were-not-exaggerated/

Yes this would have been the next step in my series of system integration with the new lotusscript classes but no worries there is lots of great services that also can be integrated.

What is a service that you would like to be able to integrate again in Domino?

You never know that service might be added to my list.

Posting to Slack using Lotusscript

Integrating Slack into your domino applications is quite straight forward and we can actually reuse the same code as for Microsoft Teams. But first lets see what you need to do in your slack channel.

And select add an app

And Select Build in the top right corner and start building.
Now you can create your application and select the channel for it.

Create a Slack App for IBM Domino

Next step is to active incoming webhooks

Using incoming webhooks to post to Slack

You will now get a unique post URL for this Slack channel when you want to post application messages.

Now over to Domino designer

  1. Create a Lotusscript agent
  2. Add the following code
Dim session As New notessession
Dim SlackURL As String,Body As String,Message as string
message="Domino 10 Talks"
SlackURL="<Paste the Slack URL here>"
Dim http As NotesHTTPRequest
Set http=session.CreateHTTPRequest()
Body=|{"text":"|+Message+|"}|
Call http.SetHeaderField("ContentType","application/json")
Call http.Post(SlackURL,Body)
	

This is how you simply post messages to a slack channel with Domino 10. Check out how to post to Microsoft teams if you haven’t