ShowTable of Contents
AddressBooks
This button gets the server and database names of the address books for the current session.
var books = session.getAddressBooks().iterator();
requestScope.status = "Address books for current session";
while (books.hasNext()) {
var db:NotesDatabase = books.next();
var dbname = db.getFileName();
var sname = db.getServer();
if (sname == "") {
sname = "Local";
}
requestScope.status += "\n" + sname + " " + dbname;
}
CommonUserName
This computed field displays the common user name, server name, and distinguished user name for the current session.
var server = session.getServerName();
if (server != "") {
server = " on server " + server;
} else {
server = " locally";
}
return "You are logged in as " + session.getCommonUserName() +
server + ". Your full name is " + session.getUserName() + "."
EffectiveUserName
This computed field displays the effective user name for the current session.
return "You are logged in effectively as " + session.getEffectiveUserName()
HttpURL
This computed field returns the Domino URL of the server if HTTP protocols are in effect.
var url = session.getHttpURL();
if (url.length == 0) {
url = "Not HTTP"
}
return url
IsConvertMIME
This button dumps information and content from a document in MIME format. The document must not be converted to rich text.
session.setConvertMime(false); // Do not convert MIME to rich text
var dc:NotesDocumentCollection = database.FTSearch(requestScope.token);
if (dc.getCount() > 0) {
// Get first document that matches user search token
var doc:NotesDocument = dc.getFirstDocument();
requestScope.status = doc.getItemValueString("subject");
var me:NotesMIMEEntity = doc.getMIMEEntity();
if (me != null) {
// Dump MIME information
requestScope.status += "\nContent type:\t" + me.getContentType();
requestScope.status += "\nContent subtype:\t" + me.getContentSubType();
requestScope.status += "\nCharacter set:\t" + me.getCharset();
requestScope.status += "\nEncoding:\t\t" + me.getEncoding();
requestScope.status += "\n*Headers*";
requestScope.status += "\n" + me.getHeaders();
// Dump MIME content
if (me.getContentType().equals("multipart")) {
if (!me.getPreamble().equals("")) {
requestScope.status += "\n\nPreamble:\t" + me.getPreamble();
}
var child1:NotesMIMEEntity = me.getFirstChildEntity();
while (child1 != null) {
requestScope.status += "\n\n*Content of child*";
requestScope.status += "\n" + child1.getContentAsText();
var child2:NotesMIMEEntity = child1.getFirstChildEntity();
if (child2 == null) {
child2 = child1.getNextSibling();
if (child2 == null) {
child2 = child1.getParentEntity();
if (child2 != null) child2 = child2.getNextSibling();
}
}
child1 = child2;
}
} else {
requestScope.status += "\n\n*Content*";
requestScope.status += "\n" + me.getContentAsText();
}
} else {
requestScope.status += "\nNot mime"
}
} else {
requestScope.status = "No match";
}
session.setConvertMime(true); // Restore MIME setting
IsOnServer
This computed field returns a different message depending on the environment.
var title = database.getTitle();
if (session.isOnServer()) {
return title + " running on " + session.getServerName();
} else {
return title + " running locally";
}
IsTrackMillisecInJavaDates
This computed field displays the current time down to milliseconds.
session.setTrackMillisecInJavaDates(true);
var dt:NotesDateTime = session.createDateTime("Today");
dt.setNow();
var h = dt.toJavaDate().getHours().toFixed();
var m = dt.toJavaDate().getMinutes().toFixed();
var s = dt.toJavaDate().getSeconds().toFixed();
var ms = dt.toJavaDate().getMilliseconds().toFixed();
return h + " hours, " + m + " minutes, " + s + " seconds, " + ms + " ms";
NotesVersion
This computed field displays the Notes version and platform of the server.
return "Running Notes " + session.getNotesVersion() +
" on " + session.getPlatform() + "."
OrgDirectoryPath
This computed field prefixes the organization directory, if any, to a database name.
try {
var org = session.getOrgDirectoryPath();
var fn = "foo.nsf";
if (!org.equals("") && !org.endsWith("\\")) {
org = org + "\\";
}var db:NotesDatabase = session.getDatabase("", org + fn);
return db.getTitle()
} catch(e) {
return e.toString()
}
Platform
This computed field displays the NotesĀ® version and platform for the current session.
return "Running Notes " + session.getNotesVersion() +
" on " + session.getPlatform() + "."
ServerName
This computed field displays the common user name, server name, and distinguished user name for the current session.
var server = session.getServerName();
if (server != "") {
server = " on server " + server;
} else {
server = " locally";
}
return "You are logged in as " + session.getCommonUserName() +
server + ". Your full name is " + session.getUserName() + "."
UserGroupNameList
This computed field displays the group names for the current user.
var groups = session.getUserGroupNameList();
if (groups.size == 0) {
return "No user groups"
} else {
var out = "User group names: ";
var iterator = groups.iterator();
var name:NotesName = null;
while (iterator.hasNext()) {
name = iterator.next();
out = out + " " + name.getAbbreviated();
}
return out;
}
UserName
This computed field displays the common user name, server name, and distinguished user name for the current session.
return "You are logged in as " + session.getCommonUserName() +
" on server " + session.getServerName() +
". Your full name is " + session.getUserName() + "."
UserNameList
This computed field displays the common user name plus any alternate name.
var ulist = session.getUserNameList();
var primary:NotesName = ulist.firstElement();
var out = primary.getCommon();
if (ulist.size > 1) {
var secondary:NotesName = ulist.lastElement();
out = out + " (" + secondary.getCommon() + ")"
}
return out;
UserNameObject
This computed field displays the common user name for the current session.
return session.getUserNameObject().getCommon()
evaluate
This button changes the
subject item of all documents in a database view to proper case.
var view:NotesView = database.getView("main");
var doc:NotesDocument = view.getFirstDocument();
while (doc != null) {
var eval = session.evaluate("@ProperCase(subject)", doc);
doc.replaceItemValue("subject", eval);
doc.save();
var tmpdoc = view.getNextDocument(doc);
doc.recycle();
doc = tmpdoc;
}
freeTimeSearch
This button finds the first free time slot for two persons until the end of the next day.
// Set up the time range
var start:NotesDateTime = session.createDateTime("Today");
var end:NotesDateTime = session.createDateTime("Today");
start.setNow();
end.setNow();
end.adjustDay(1);
var window:NotesDateRange = session.createDateRange();
window.setStartDateTime(start);
window.setEndDateTime(end);
// Set up the names
var names = new java.util.Vector();
names.addElement("Roberta Person");
names.addElement("Neal Strong");
// Find the free time
var freetime:java.util.Vector = session.freeTimeSearch(window, 60, names, true);
if (freetime == null) {
requestScope.free = "No time slots";
} else {
requestScope.free = "First available time slot\n";
var dr:NotesDateRange = freetime.firstElement();
var sdt:NotesDateTime = dr.getStartDateTime();
var edt:NotesDateTime = dr.getEndDateTime();
requestScope.free = requestScope.free + sdt.getLocalTime() + " start\n";
requestScope.free = requestScope.free + edt.getLocalTime() + " end";
}
getCurrentDatabase
This computed field returns the title of the current database.
return database.getTitle()
getDatabase
This computed field returns the title of
names.nsf in the local directory.
var db:NotesDatabase = session.getDatabase("", "names", false);
if (db == null) {
return "No local address book";
} else {
return db.getTitle();
}
getDbDirectory
This value formula for a list box displays the names of all the databases in the current directory.
var out = new Array();
var dir:NotesDbDirectory = session.getDbDirectory("");
var db:NotesDatabase = dir.getFirstDatabase(NotesDbDirectory.DATABASE);
while (db != null) {
out.push(db.getFileName());
db = dir.getNextDatabase();
}
return out
getEnvironmentString
This computed field displays the value of a non-system environment variable.
var v = session.getEnvironmentString("HomeTown");
if(v == "") {
return "No home town"
} else {
return v
}
getEnvironmentValue
This computed field displays the value of a system environment variable.
var v = session.getEnvironmentValue("PANEL_SIZE_XY", true);
if(v == null) {
return "Panel size XY not set"
} else {
return v
}
getURLDatabase
This computed field displays the file name and title of the default Web Navigator database.
var db = session.getURLDatabase();
var fn = db.getFileName();
var title = "";
if (db.isOpen()) {
title = db.getTitle();
} else {
title = "Database not open"
}
return fn + " (" + title + ")"
getUserPolicySettings
This button dumps the mail policy settings for a user.
var doc:NotesDocument = session.getUserPolicySettings(
"server2/Acme", "Jo User",
NotesSession.POLICYSETTINGS_MAIL);
if (doc == null) {
requestScope.status = "No policy document";
} else {
var items = doc.getItems().iterator();
while (items.hasNext()) {
var item:NotesItem = items.next();
requestScope.status += item.getName() + " = " +
item.getText() + "\n";
}
}
hashPassword
This button is for a page where the user enters values for a new password and its verification. The code hashes the text password then verifies the text verification against the hashed value.
var cpw = document1.getItemValueString("passwordCreate");
var vpw = document1.getItemValueString("passwordVerification");
if (cpw.length < 6 || vpw.length < 6) {
requestScope.status = "Password must be at least 6 characters";
} else {
var pw = session.hashPassword(cpw);
if (session.verifyPassword(vpw, pw)) {
document1.replaceItemValue("password", pw);
document1.save();
requestScope.status = "Password accepted";
} else {
requestScope.status = "Password verification failed";
}
}
resolve
This computed field gets the URL for the current database and resolves it.
var theURL = database.getURL();
var target:NotesDatabase = session.resolve(theURL);
return theURL + " " + target.getTitle()
This computed field constructs a URL for the current database using its file name and resolves the URL.
var theURL = "notes:///" + database.getFileName() + "?OpenDatabase";
var target:NotesDatabase = session.resolve(theURL);
return theURL + " " + target.getTitle()
This computed field constructs a URL for the current database using its replica ID and resolves the URL.
var theURL = "notes:///" + database.getReplicaID() + "?OpenDatabase";
var target:NotesDatabase = session.resolve(theURL);
return theURL + " " + target.getTitle()
setEnvironmentVar
This button sets a non-system environment variable.
session.setEnvironmentVar("HomeTown", "Tokyo")
This button sets the value of a system environment variable.
session.setEnvironmentVar("PANEL_SIZE_XY", 414, true)
verifyPassword
This button is for a page where the user enters values for a new password and its verification. The code hashes the text password then verifies the text verification against the hashed value.
var cpw = document1.getItemValueString("passwordCreate");
var vpw = document1.getItemValueString("passwordVerification");
if (cpw.length < 6 || vpw.length < 6) {
requestScope.status = "Password must be at least 6 characters";
} else {
var pw = session.hashPassword(cpw);
if (session.verifyPassword(vpw, pw)) {
document1.replaceItemValue("password", pw);
document1.save();
requestScope.status = "Password accepted";
} else {
requestScope.status = "Password verification failed";
}
}