Expose IBM Domino User Information as JSON

Mark Barton
InstructorMark Barton

Share this video with your friends

Send Tweet
Published 4 years ago
Updated 3 years ago

This lesson will demonstrate how to use simple Domino design elements like a page and @formulas to output a logged in users application roles and registered name.

This additional information is passed to a client application via the Node.js application. These roles could then be used to control visibility of user interface elements.

Instructor: [00:00] To get more user information from Domino, including what roles the user has, I find the easiest way is to create a simple page. I'm using a page because a form it has new fields required on this. We're going to call the page User. I'm storing this page inside my demo database.

[00:16] The first thing we want to do is change the MIME type for the page so that it returns JSON data. Then, we're going to use simple computed values. We'll start with a user object. We'll use a string [inaudible] here. This object will have two properties. It'll have the user name, and for this computed value, we'll use a simple @UserName, and we'll wrap it with a @name so we get the common name.

[00:53] Then, our second property will be roles. This could be a multivalue, so it's going to potentially be an array. We want to remove the square brackets and the dollar [inaudible] that Domino will automatically send. We'll start with a temporary variable. We'll add a trim and an @replace substring.

[01:13] We're going to work on user roles. We'll remove one square bracket, the other square bracket, and $$ workline, and we're going to replace those with empty quotes. If we don't have any roles, then we want to return a blank value, else we want to implode them and wrap them in string quotes.

[01:41] We'll escape that. We'll use a comma as a string delimiter, because that's what the JavaScript array delimiter is. We will now test that in the browser. I've opened my database and opened my user page in the browser. First one I get is the standard Domino login, because it's a secure database.

[02:00] I sign in. I then get back the JSON data that we've defined using the computed values. My test user actually has those roles. They're listed here in the ACL. Let's go forward and use those within our application.