Lotus Notes FAQ Visit Our Sponsor!

Lotus Notes Frequently Asked Questions
(Notes/Domino 8.x)

A. Administration Tips


1. How do you run the Compact process on a schedule?

2. Does Domino Support Wildcard SSL Certificates?
3. What TCP/IP Port Does Lotus Traveller Use?
4. How do you install Sametime 8.x on an unsupported OS?
5. Why is Percentage Used always 0% for Databases Listed in catalog.nsf?
6. How Do You Rebuild Busytime?
7. How Do You Fix the "Error connecting to server " Error?
8. How do you upgrade the database ODS?
9. How do you see if Traveler is still resyncing user data?
10. How do you import a wildcard domain certificate into Domino?
11. Can you run the NotesSQL ODBC Drivers on 64-bit Windows?
12. How do you send Server crash reports to IBM automatically?
13. Can you hide the failover prompt?
14. Does "Optimize document table map" Cause View Index Corruption?
15. Why does the server process use 100% cpu time on Linux?
16. Why does the catalog task show this error: "Unable to replace obsolete catalog. The name is not in the list"?
17. Why do I get the "Maximum allowable documents exceeded for a temporary index" in the Notes Log?

B. Domino


1. How do you make a database open a form by default from the web?
2. Why Don't Domino's Java Applets Show Up for Mac Web Browsers?
3. How do you control what is used to edit a rich text field on the web?

C. Education and Training


1. Learning Plug-In

D. Mailing Lists


1. LNotes-L on Yahoo

E. Programming Tips


1. How do you delete a profile document?
2. How do you calculate the week number in a year of a given date?
3. What Are Domino's Field Size Limits?
4. How do you get the HTML for a Rich Text field?
5. How do you enable Java 5 (1.5) support in Notes 8?
6. How do you disable NSD so exceptions go to Visual Studio?
7. Why does my C API program crash when running on 64-bit Windows?
8. What causes "Entry Not Found In Index" Errors?

F. Programming Tips - LotusScript


1. How do you open a File Dialog in LotusScript?
2. How do you edit a rich text field in an open document and redisplay it?
3. How do you find out if there is default view?

G. Web Sites


1. Notes Related Web Sites


How do you run the Compact process on a schedule?

Here is an example program document you can use. Make sure the Notes directory is in your system PATH.

Basics
Program name: $COMPACT.EXE
Command line: -S 5
Server to run on: ServerName/Domain
Comments: Compact databases with more than 5 percent whitespace.

Schedule
Enabled/disabled: ENABLED
Run at times: 10:10 PM each day
Repeat interval of: 0 minutes
Days of week: Wed, Sat


Note that if you are running DAOS in Domino 8.x+, you'll have to add the -B flag for the database to shrink free space properly.


Does Domino Support Wildcard SSL Certificates?
Thanks to Joe Walters for putting up this detailed description of how to set this up:

Configuring a wildcard certificate with Domino is very similar to configuring a single-host SSL certificate.� So, most of the process below you'll already be familiar with if you've ever set up SSL on Domino.� Here's how I would configure a new wildcard certificate in my test environment.� I'll include some caveats and comments at the end, so save your questions. :-)

My scenario:

I have a Domino 7.0.x server, Kakadu/WashU, running on Windows Server 2003.� It's Program directory is C:\Lotus\Domino and it's Data directory is D:\Lotus\Domino\Data.� I want to configure an SSL certificate for Kakadu, but I know later, I'll be asked to configure SSL certificates on other Domino servers, so I opt to implement a wildcard certificate. �

To save some time and hassle later, I picked an unused local drive letter (V:) and mapped a drive to Kakadu's D: drive (from a windows cmd prompt, I type net use V: \\kakadu\d$). �

Creating a Key Ring File:

The first thing I need to do to configure any SSL certificate in Domino is create a key ring file.�

I open the Domino Server Certificate Administration (CERTSRV.NSF) database on Kakadu (at this point, you may have to escape out of the About Database document), then click on Create Key Ring.

The key ring file is used to store the certificates and it ultimately needs to reside in the Domino server's data directory.� (This is where my mapped drive helps me out a little.) �

In the Key Ring File Name: field, I enter the path to where I want my key ring file to reside (in my Domino server's data directory, via my locally mapped V: drive).

Next, I enter a password and confirm it.� (Document and secure this password somewhere.� Do this now.� If you're like me, you won't remember it five minutes from now.)

I then select the Key Size I want to use for my key ring.� There's no reason for me not to choose 1024 for a more secure encryption strength.

Everything's been normal SSL configuration to this point.� But now, in the Common Name field, I need to use the wildcard notation instead of the fully qualified domain name (FQDN) of my server, as I normally would.� My Domino server's FQDN is actually kakadu.wustl.edu, so the proper wildcard notation should be *.wustl.edu.

The rest of the fields (organization, Organizational Unit, City or Locality,� State or Province, and Country) should be filled in just as you would if you were configuring a single server SSL certificate.

When I've finished filling out this form, I click the Create Key Ring button at the bottom.

A dialog box pops up indicating I've successfully created my key ring file.� I click OK and at this point, if I were to go out to Kakadu's Domino data directory, I would see my .kyr file (wildcard1024.kyr).� I should also see a wildcard1024.sth file in the data directory.� The .kyr file is password-protected in a binary format (not encrypted).� The .sth file is the Stash file, and it stores the password to the .kyr file so the server can use it unattended.


Generating a CSR:

Now that I have a key ring file to store my certificates, I need to generate a CSR (Certificate Signing Request).� Still in certsrv.nsf, I now click on Create Certificate Request.


A Create Server Certificate Request form opens, and I confirm that the Key Ring File Name path includes the full path to the key ring file I created previously.� All of this auto-filled for me, so I just click the Create Certificate Request button.�

Now a Certificate Request Created dialog box will pop up.� Here you'll need to copy to the clipboard everything you see in the bottom window including the -----BEGIN NEW CERTIFICATE REQUEST----- text at the beginning and the -----END NEW CERTIFICATE REQUEST----- text at the end.� (I suggest you paste this into a text file for temporary safe keeping as well.� You can safely delete it once you've finished the whole process.)� Click OK once you've copied the certificate to the clipboard.



Acquire your Wildcard SSL Certificate from a Third-Party Certificate Authority:

Now that you have a CSR, you can go to a third-party SSL provider's website to get a wildcard certificate.� Each provider's process will be a little bit different, but they will all want four things from you.

1) You need to be the owner of the domain name for which you want to get the wildcard certificate, so be prepared to provide some type of proof to the third-party CA that you're authorized to request the certificate.

2) You'll also need to provide some type of proof that your organization is a legitimate one.

3) You'll need to have the CSR you generated a moment ago.

4) Lastly, you'll need to pay for the certificate.� If you have a credit card, preferably a company card, this is definitely the easiest way to go.� I've had to pay for certificates with a purchase order in the past and the delay was irritating.� In fact, some CAs may not accept anything but a credit card anyway.

In this example, I'm purchasing my wildcard certificate from Digicert, but the process is very similar between Verisign, Thawte, Digicert, and I imagine most other third-party CAs.

Installing the Wildcard Certificate into your Key Ring file:

Once you've finished purchasing your wildcard certificate, your CA will let you know how to retrieve your certificate.� (Typically, you'll create a login account to their website where you can retrieve them.) �

Depending on who you purchase your certificate from, the key ring file may or may not already have Trusted Root and Intermediate certificates installed.� So the best bet is to install the Trusted Root and Intermediate certificates, assuming they're not already there.� You'll want to install the Trusted Root certificate first, then any Intermediate certificates, and lastly, install your wildcard certificate into the key ring file.

I open the Domino Server Certificate Administration (CERTSRV.NSF) database on Kakadu, then click on Install Trusted Root Certificate into Key Ring.

In the Install Trusted Root Certificate form that opens, I make sure the path to my key ring file is correct (this should autofill for me).� A label is required, so I enter a label appropriate to the cert I'm installing.� I also select Clipboard for the certificate source, and paste the certificate into the form.� Lastly, I clicked the Merge Trusted Root Certificate into Key Ring button.

A confirmation window appears, which reads the certificate data and presents it in a human readable format.� Everything looks correct, so I click OK.

In this case, the Trusted Root certificate I just attempted to install was already in the key ring.� No problem.� I just move on to the install any other trusted root/intermediate certificates I may need.

Again, I select Install Trusted Root Certificate into Key Ring.


And again, I verify the path to my key ring file, enter an appropriate label, paste the certificate into the form, and click the Merge Trusted Root Certificate into Key Ring button


Again, a confirmation pop-up appears and everything looks fine.� I click OK.

This time, I see that I did not have this certificate in the key ring yet, so it's good that I did this.� Having this intermediate certificate installed completes the certificate chain from the trusted root CA, through the intermediate certificate, and then to my wildcard SSL certificate.


Now I'm finally� able to install my wildcard certificate into my key ring file.� This time, I choose Install Certificate into Key Ring.


Again, I verify the path to my key ring file.� This time, however, I don't need to enter a label.� I still select the Clipboard option, paste the certificate into the form, then click the Merge Certificate into Key Ring button.

A confirmation dialog appears, and it's important to verify everything's correct.� It all looks good, so I click OK.

WOOHOO!! I've merged a wildcard certificate into my key ring file! Click OK.


Now you can configure domino for SSL as you would before.� Configuring SSL via web configuration or internet site documents is no different with wildcard certs than single-server certs.� To use the wildcard certificate on a different server, I only need to copy my key ring file (wildcard1024.kyr) and a stash file (wildcard1024.sth) located in Kakadu's data directory to the data directory of another Domino server.

Additional Notes:

Because this is a wildcard certificate, you need to take precautions to keep the certificate secure.� Of course, you should be protecting your file system from inappropriate access anyway.
I chose to use the clipboard method to merge certificates into my key ring file.� The other option is to specify a file (e.g. TrustedRoot.crt, DigiCertCA.crt and your_domain_name.crt).� Both options work equally well.� This is a personal preference.
I chose to map a drive to my Domino server's data directory.� The reason I did this was to avoid having to later copy my key ring file (wildcard1024.kyr) and stash file (wildcard1024.sth) up to my Domino server.� Again, a personal preference thing.� If you don't have a windows server, you could possibly mount a samba share, or just do everything with your local Notes client and copy everything up when you're done.� Personal preference again.
Now that I have a wildcard certificate, I'll store both the .kyr and .sth files in a highly secured database in Notes for safe keeping.� I also document when the certificate will expire in a central change managment database, then add a reminder on my personal calendar to send me a reminder a month or two prior to the expiration date, so I don't have any expiration surprises.
Lastly, the gobbledy gook text above for the certificates is not legit.� It's fictitious, but I think the screen shots are a fair representation of the process you'll encounter if you choose to configure a wildcard certificate in Domino.
An extra word of caution:
Depending on your browser, Wildcard certificates may work at only one domain level only.� For instance with my *.wustl.edu certificate, I can secure any website whose FQDN is in the format of domainlevel3.wustl.edu (e.g. kakadu.wustl.edu, dipperu.wustl.edu, etc.).� Regardless of the browser, these domain names will all have a valid certificate chain.� Things get trickier if I try to secure a website whose FQDN is in the format of domainlevel4.domainlevel3.wustl.edu (for instance, www.kakadu.wustl.edu).� www. is now a fourth level domain name, and my wildcard is specifically registered as *.wustl.edu, not *.*.wustl.edu.� Mind you, the last I checked, Firefox, Opera, and Mozilla had no problems applying a wildcard certificate to multiple levels in this way, but Microsoft IE and Safari throw warnings to the end user when they encounter this.

What TCP/IP Port Does Lotus Traveller Use?
AutoSync function uses TCP/IP port 8642. The servlet engine (http task) also has to be running on the server.

How do you install Sametime 8.x on an unsupported OS?
From Anar Taghiyev:

To install Sametime 8 on CentOS, run the following command as root in the Terminal window:
export STSkipOSCheck=true

and proceed with the rest of the installation.

Why is Percentage Used always 0% for Databases Listed in catalog.nsf?
Getting the percentage used for a large database is extremely resource intensive, so this is disabled by default in Notes 8.x.
If you really want to enable this, you can add this to your notes.ini:

CATALOG_DISK_USAGE=1


How Do You Rebuild Busytime?

The cleanest way to do this is to shut down the server and delete busytime.nsf and let the server rebuild this if your busytime database is corrupted. If you have a clustered setup, you have to shut down the servers in your cluster and delete the clubusy.nsf DB.

An alternative way that may not require server reboots:
- shut down the calconn, sched, and rnrmgr tasks
- delete all documents in the busytime.nsf or clubusy.nsf DBs or just delete the DB after a "dbcache flush"
- restart the calconn, sched, and rnrmgr tasks
- instead of restarting the tasks, you may be able to do "tell sched validate" and "tell rnrmgr validate" from the console


How Do You Fix the "Error connecting to server " Error?

The Domino server when it has multiple network cards, sometimes doesn't know how to contact itself and you get messages of the form "Error connecting to server <itself>: Remote system no longer responding". Even though DNS has the IP address for the server, Domino sometimes needs this IP address put in the local hosts file directly. On Windows, this is in the \windows\system32\drivers\etc directory.


How do you upgrade the database ODS?

The Notes 8 and 8.5 ODS (object data store...aka, NSF file) do not use the latest version by default. The 8.x version lets you compress design elements and data to save disk space and also use DAOS (8.5) to save space for attachments. Lotus does not enable the new ODS when you install the server because some backup and antivirus programs don't know what to do with the new format.

If you want the 8.5 ODS, add "Create_R85_Databases=1" to your notes.ini file for the server.
If you want the 8.0 ODS, add "Create_R8_Databases=1" to your notes.ini file for the server.
These switches will let Domino create databases in the new format for new databases.

To convert existing databases to the new format, you have to run the compact command using these parameters:
-c (copy style compact)
-n (design compression)
-v (data compression)
-daos on (to pull attachments out of the NSF and into DAOS -- assuming DAOS has been configured on the server document).

The command line would be (run it from the command line to convert names.nsf and log.nsf and other databases the server might be using at the time:

[n]compact -c -n -v -daos on 


How do you see if Traveler is still resyncing user data?
In the server console, type "tell traveler log syncml on". This enables logging of the data.
In the traveler\logs\syncml directory, you'll see *_Ping_in.xml files to indicate that a user's device is pushing data.


How do you import a wildcard domain certificate into Domino?

From Ninke Westra:

Create a server keyring (.kyr) file, for example using the certsrv.nsf database that's present on just about every server, doesn't matter if it's on the server that you want to use the keyring with or not since the keyring file is created locally to your client, not on the server.

Select Create Key Rings & Certificates in the navigator and click 1. Create Key Ring
Under Keyring informationyou enter the filename (keyring.kyr) and password that you want to set for this keyring file.
For Keysizeyou can select a keysize that will be used when creating certificate requests using this keyring.
Disinguished Name has some mandatory fields
�� Common Name���your server's fully qualified hostname (when generating a certificate request or *.domainname for a wildcard request
Organization��������� Organisation name
� Organizational Unit
��� (optionall)
��� City������������������������ (optional)
��� State��� ����������������� Province/State
��� Country���������������� Two letter country code.

The next step is 3. Install Trusted Root Certificate into Key Ring
Enter Certificate Information an identifying label for the certificate signer's certificate
You can choose to either import the root certificate from a .crt/.cer file or paste from clipboard.
Click Merge Trusted Root Certificate into Key Ring
Enter the password you picked at step 1. (create key ring)

To import existing wild card certificates (pcks12 format, .pfx/.p12 file) into a Domino keyring file you need IBM's [ftp] GSK5 IKeyMan.
(I read somewhere that this tool might not work in Windows 2003/Vista+ but I can not confirm that).

Extract the gsk5-ikeyman.zip file into a directory that has no spaces in the name (I used C:\gsk5)
Start the command line shell, change directory to the directory where you extracted gsk5 to and execute the following command: gskregmod.bat Add
Next run IKeyman by executing runikeyman.bat.
Open the keyfile.kyr file that we created earlier and enter the keyring password.
Select Personal certificates and click Import

Select the wildcard certificate file (.pfx/.p12) and enter the certificate's password.

Shutdown IKeyman and copy the keyfile.kyr and matching keyfile.sth� to your Domino server's data directory.

Configure your Domino server to use this keyring file and restart the http task (or restart domino).


Can you run the NotesSQL ODBC Drivers on 64-bit Windows?
The NotesSQL driver is a 32-bit ODBC driver, so you have to register it as such

ODBC on running on a 64-bit-based operating system has two sets of system DSN settings stored in the Windows Registry.
32-bit client applications use the 32-bit settings. 64-bit applications use the 64-bit settings.

If you run "%SystemRoot%\SysWOW64\odbcad32.exe", you modify the 32-bit settings.
If you run "%SystemRoot%\system32\odbcad32.exe", you modify the 64-bit settings (this is the one run from the Control Panel --> Administrative Tools --> Data Sources --> ODBC).

You must register the System DSN for the ODBC32 drivers with SysWOW64\odbcad32.exe.


How do you send Server crash reports to IBM automatically?
In the notes.ini for the server, set
Crash_SendToIBM=1

IBM will get the fault reports automatically so they can analyze them and prioritize fixes for the text maintenance release or hotfix.


Can you hide the failover prompt?

As of Notes 8, you can. Add
HidePromptFailoverInc=1
to the Notes users' notes.ini and the Notes client will automatically fail over to the next server in your cluster.


Does "Optimize document table map" Cause View Index Corruption?

This is a known issue that happens with workflow applications that change forms for the documents as the documents go through the workflow. As long as your database does not do this, you can use this to get faster view performance. This is documented well on Nathan Freeman's Blog.

Lotus knows about this and won't fix it until they hear enough complaints from customers, so if you have a maintenance plan and want to use up one of your support tickets, feel free to do so :-)


Why does the server process use 100% cpu time on Linux?
There was a kernel change in roughly 2.6.37 that causes statistics to suck 100% of CPU time, even though the system is lightly loaded.

You can disable this by adding this to your Notes.ini and restarting the Domino server.
PLATFORM_STATISTICS_DISABLED=1

Thanks to Oliver Regelmann for getting this from Lotus support.


Why does the catalog task show this error: "Unable to replace obsolete catalog. The name is not in the list"?
Make sure that LocalDomainCatalogServers is in the ACL of the catalog.nsf Database Catalog as Editor and Server Group. If it's not there, the catalog task can't update the documents in the database and puts up this cryptic error :-P

Why do I get the "Maximum allowable documents exceeded for a temporary index" in the Notes Log?

Usually, an agent has a document filter criteria that is causing a temporary full text index to be created.
Simplify the filtering criteria or full text index the database to take the load off your server.

You can work around the limit of 5000 documents by adding (as of Notes 6) this:

  TEMP_INDEX_MAX_DOC=<
number> 

into your server's notes.ini but this isn't recommended because it will increase the load on your server.


How do you make a database open a form by default from the web?

Thanks to Carl Tyler:

Create a Navigator, call it WebNavigation it can be totally empty, as it doesn't really get used.
Create a form with the contents you want called $$NavigatorTemplateDefault
Now set the web launch options for the database to open the navigator WebNavigation and it will use the form $$NavigatorTemplateDefault

Why Don't Domino's Java Applets Show Up for Mac Web Browsers?
For some reason, this is disabled by default in all Domino installations (as of this FAQ, at least to 8.5.2FP1).
Check the domino/data/browser.cnf file. You'll see a section for the Java editor applet as follows:

## DisableEditorApplet - Boolean indicating whether browser can handle the Editor Applet
Property DisableEditorApplet Boolean False
Rule True MSIE [0-9].*\; Macintosh # IE on MAC platform
Rule True MSIE [0-9].*\; Mac_PowerPC # IE on MAC platform
Rule True ^Mozilla/[0-9].*\(Macintosh # Netscape on MAC platform
Rule True ^Mozilla/[0-9].*\(Mac_PowerPC # Netscape on MAC platform
Rule True Notes # Notes browser

Change the two highlighted values from True to False to enable Java applets for Firefox on the Mac.


How do you control what is used to edit a rich text field on the web?

There is a wiki article that describes how to use the Best Fit option.

Note that you have to modify your browser.cnf article in 8.5 because it was shipped with settings that disable the Java editor for Safari/Chrome.


Learning Plug-In

Lotus has created a learning plug-in for Lotus Notes 8+ (Standard/Eclipse client only).

LNotes-L on Yahoo

Subscribing
You can get more info on the web site for this user group:
http://tech.groups.yahoo.com/group/lnotes-l-new/


How do you delete a profile document?

You have to use LotusScript:

  Set doc = db.GetProfileDocument(profilename)
  Call doc.Remove


How do you calculate the week number in a year of a given date?

This formula satisfies ISO 8601:1988:

REM "This formula satisfies ISO 8601:1988";
REM "Formulae updated : 08.28.1997 ";
REM "by Stephen P.R. Renton (sprenton@mcmail.com)";
REM "Version: 1.01";
REM "Tested on : Lotus Notes Release 4.5";

REM "D is the date of interest.";
D := @TextToTime(@Prompt([OKCANCELEDIT]; "Enter Date"; "Please enter a
date to convert to a week number:"; ""));
REM "D := [31/12/95]";

FirstOfYear := @Date(@Year(D); 1; 1);
LastOfYear := @Date(@Year(D); 12; 31);
FirstDayNum := @Weekday(FirstOfYear);
LastDayNum := @Weekday(LastOfYear);

REM "ISO weeks start on Monday and ends on Sunday.";
ISOFirstDayNum := @If(FirstDayNum = 1; 7; FirstDayNum - 1);
ISOLastDayNum := @If(LastDayNum = 1; 7; LastDayNum - 1);

REM "The first and last ISO week is the first";
REM "and last ISO week to include Thursday";
IsFirstWeek := 7 - ISOFirstDayNum > 2;
IsLastWeek := 7 - ISOLastDayNum < 4;
REM "The date of the first day of the first ISO week";
ISOFirstDay := @If(IsFirstWeek;
            @Adjust(FirstOfYear; 0; 0; 1 - ISOFirstDayNum; 0; 0; 0);
            @Adjust(FirstOfYear; 0; 0; 8 - ISOFirstDayNum; 0; 0; 0));
REM "The date of the last day of the last ISO week";
ISOLastDay := @If(IsLastWeek;
            @Adjust(LastOfYear; 0; 0; 7 - ISOLastDayNum; 0; 0; 0);
            @Adjust(LastOfYear; 0; 0; -ISOLastDayNum; 0; 0; 0));

REM "Date outside ISOFirstDay and ISOlastDay";
REM "are from the previous or next year";
REM "Return the ISO week number and exit";

FirstWeekNextYear := @If(D > ISOLastDay; @Return(@Prompt([OK]; "FWNY";
@Text(@Year(D)+1) + "W01")); NULL);

REM "I suspect this is where Julian dates would be useful";
REM "A recursive call could be used in a real language";
LastWeekLastYear := (D - @Adjust(FirstOfYear; -1; 0; 0; 0; 0; 0))/60/60/24/7;
AdjustLastWeek := 1 - (LastWeekLastYear - @Integer(LastWeekLastYear));
@Set("LastWeekLastYear"; LastWeekLastYear + AdjustLastWeek);
@If(D < ISOFirstDay;
@Return(@Prompt([OK]; "LWLY"; @Text(@Year(D) - 1) + "W" +
@Text(LastWeekLastYear))); NULL);

REM "If you get this far, the date falls into an ISO week this year";
REM "Convert the difference in seconds to weeks";
NumWeeks := (D - ISOFirstDay)/60/60/24/7;

REM "Fractions indicate that the date falls";
REM "in the middle of the ISO week";
WeekAdjust := 1 - (NumWeeks - @Integer(NumWeeks));
ISOWeekNum := NumWeeks + WeekAdjust;

REM "Conform to ISO 8601 format";
Pad:=@If(ISOWeekNum<10;"0";"");
Result := @Text(@Year(D))+"W"+Pad+@Text(ISOWeekNum);

@Prompt([OK];"Week number"; Result)

Here is another version that gives you a week number in another ISO format:

REM "Formulae Calculate the Week Number(01-53) for any Date. ";
REM "The output follows the ISO 8601:1988 standard: ex 1997-W31-4 for 1997.07.31 ";
REM "Formulae writer : Nikolai Aasen (nsaa@pvv.org), UNI Storebrand, Norway";
REM "Formulae written : 1997.07.30";
REM "Formulae updated : 1997.08.04";
REM "Version  : 1.03";
REM "Tested on   :Lotus Notes 4.6PreRelease2";
REM "This formulae is available in the";
REM "Lotus Notes FAQ: http://www.keysolutions.com/NotesFAQ/";
REM "More Calendar information in http://www.pip.dknet.dk/~pip10160/calendar.html"; 
REM "ISO 8601:1988 summary at: http://quake.stanford.edu/~lyle/ISOdate/Date.html";
REM "--------------------------------------------------------------------------------------------------";             
REM "Replace D with the date of interest.";
D := [1997.31.07];

REM "**************************";
REM"Calculate some data for this Year";
REM "**************************";
FirstOfYear := @Date(@Year(D); 1; 1);
LastOfYear := @Date(@Year(D); 12; 31);
FirstDayNum := @Weekday(FirstOfYear);
REM "ISO weeks start on Monday and ends on Sunday.";
ISOFirstDayNum := @If(FirstDayNum = 1; 7; FirstDayNum - 1);

REM " Week 1 of any year is the week that contains the first Thursday in January.";
REM "=1 if 1. jan = man - thu. WeekNumber is then 1, else 0";
IsFirstWeek := 7- ISOFirstDayNum >2;

REM "The first Monday after 1. jan this Year";
FirstMonday := 9 - ISOFirstDayNum;

REM "Number of Days from 1. jan to D";
DaysToDateD:=(D-FirstOfYear)/60/60/24+1;

REM "Number of days in Year(either 365 or 366)";
DaysInYear:=(LastOfYear-FirstOfYear)/60/60/24;

REM "Number of Weeks in Year. Most years have 52 weeks, but years that start on a 
Thursday and leapyears that start on a Wednesday have 53 weeks.";
NumberOfWeeksThisYear:=@If( (ISOFirstDayNum=4 | (ISOFirstDayNum=3 & 
DaysInYear=366));53;52 );

REM "***************************";
REM"Calculate some data for last Year  ";
REM "***************************";
FirstOfLastYear := @Date(@Year(D)-1; 1; 1);
LastOfLastYear := @Date(@Year(D)-1; 12; 31);
FirstDayNumLast := @Weekday(FirstOfLastYear);
REM "ISO weeks start on Monday and ends on Sunday.";
ISOFirstDayNumLast := @If(FirstDayNumLast = 1; 7; FirstDayNumLast - 1);

REM "Number of days in Year(either 365 or 366)";
DaysInYearLast:=(LastOfLastYear-FirstOfLastYear)/60/60/24;

REM "Number of Weeks Last Year. Most years have 52 weeks, but years that start on a 
Thursday and leapyears that start on a Wednesday have 53 weeks.";
NumberOfWeeksLastYear:=@If( (ISOFirstDayNumLast=4 | (ISOFirstDayNumLast =3 & 
DaysInYearLast=366));53;52 );

REM "************************";
REM"Calculates the Week Number  ";
REM "************************";


DDayNum := @Weekday(D);
ISODDayNum := @If(DDayNum = 1; 7; DDayNum - 1);

REM"Is D in the last Week of the last Year?";
DayInLastWeek := @If((DaysToDateD<FirstMonday & IsFirstWeek = 0);
                                @Return( @Text(@Year(D)-1)+"-W"+@Text(NumberOfWeeksLastYear)+"-"+@Text(ISODDayNum));
                                 NULL);

REM "Calculate number of Complete Weeks Between D and 1.jan";
ComplNumWeeks:=@Integer((DaysToDateD-FirstMonday)/7);

REM "Are there remaining days?";
RemainingDays:=@If( (DaysToDateD+1-(FirstMonday+7*ComplNumWeeks))>0);

NumWeeks:= IsFirstWeek+ComplNumWeeks+1;

Out :=
@If(RemainingDays;
@If( (NumWeeks>52 & NumWeeks>NumberOfWeeksThisYear );
         @Return(@Text(@Year(D)+1)+"-W01-"+ @Text(ISODDayNum));
          @Return(@Text(@Year(D))+"-W"+@Right("0"+@Text(NumWeeks);2)+"-"+@Text(ISODDayNum))); 
@Return(@Text(@Year(D))+"-W"+@Right("0"+@Text(NumWeeks-1);2) +"-"+@Text(ISODDayNum)));
Out

This LotusScript version comes from Christian Meis:

'CalculateWeekNumbers: 

Option Declare


Sub Initialize
     
%REM
This short agent shows how the calendar week
function can be implemented.

Christian Meis, 09.04.1999
E-Mail: Christian.Meis@mlc.de
%END REM
     
  Dim dateval As Variant
  Dim test As String
     
  dateval = Cdat( Inputbox( "Please enter date: " ) )
  test = GetCalendarWeek( dateval )
     
  Messagebox( Cstr( dateval ) & " --> " & test )
     
End Sub


Function GetCalendarWeek( Byval inputdate As Variant ) As String
     
%REM
This function calculates the calendar week number 
(ISO standard) for a given date value. The format
function of LotusScript (parameter "ww") does not solve 
this problem. 

Monday is the first day of the week. Week #1 is the week 
that contains the 4th of January (ISO 8601). The week at the
end/beginning of the year belongs to the next/previous year,
if there are 3 days or less of that week in the year in question.

Christian Meis, 4.2.2000
%END REM
     
  Dim InputDateOffset As Integer
  Dim YearInQuestion As Integer
  Dim January4 As Variant
  Dim January4Offset As Integer
  Dim FirstMondayOfYear As Variant
  Dim January1Offset As Integer
  Dim December31Offset As Integer
  Dim weeknum As Integer
     
  ' The year value is preset with that of the input date
  YearInQuestion = Year( inputdate )
     
  ' Calculate offset to monday from the input date
  InputDateOffset = CalculateIsoWeekday( inputdate )
     
  ' Calculate offsets for the first/last day of the year
  January1Offset = CalculateIsoWeekday( Cdat( "01.01." & Cstr( YearInQuestion ) ) )
  December31Offset = CalculateIsoWeekday( Cdat( "31.12." & Cstr( YearInQuestion  ) ) ) 
     
  ' If the input date is before the 4th of January and the year starts with
  ' a friday, saturday or sunday, the week belongs to the previous year
  ' if the entered date is not a monday or tuesday
  If Month( inputdate ) = 1 And Day( inputdate ) < 4 And January1Offset> 3 And InputDateOffset > 1 Then
    YearInQuestion = YearInQuestion - 1
  End If

  ' If the input date is after the 28th of December and the year ends with
  ' a monday, tuesday or wednesday, then the week belongs to the following year
  ' if the entered date is not a saturday or sunday
  If Month( inputdate ) = 12 And Day( inputdate ) > 28 And December31Offset < 3 And InputDateOffset < 5 Then
    YearInQuestion = YearInQuestion + 1
  End If
     
  ' The 4th of January defines week #1
  January4 = Cdat( "04.01." & Cstr( YearInQuestion ) )
     
  ' Offset to the monday of week #1 
  FirstMondayOfYear = Cdat( January4 - CalculateIsoWeekday( January4 ) )
     
  ' The time range between the monday of week #1 and the monday
  ' of the week in question is divided by 7, plus 1 for the first week
  weeknum = ( inputdate - InputDateOffset - FirstMondayOfYear ) \ 7 + 1
     
  ' The return value is a string with the week number and the year
  GetCalendarWeek = Cstr( weeknum ) & " " & Cstr( YearInQuestion )
     
End Function


Function CalculateIsoWeekday( tmpdate As Variant ) As Integer
     
%REM
This function converts the weekday-numbers from the
standard function to an offset acc. to the ISO version
monday -> 0, ... , sunday -> 6
%END REM
     
  Dim n As Integer
     
  n = Weekday( tmpdate )
   
  If n = 1 Then ' sunday to end of week
    n = n + 7
  End If
     
  CalculateIsoWeekday = n - 2
     
End Function

This version for 53 week years comes from Bill Westaway (Bill.Westaway@fmr.com):

The following "week of the year" formula was adopted from the set that shows on your web site.
It is for applications that require 53 week years because the last few days of the year still occur in a calendar year (government reporting or payroll support would be good examples). 2002 is a good example of a 53 week year.
(you can actually get a 54th week by this definition - this formula will also work then)

The formula works in views, fields, and agents and should work for every Notes/Domino release 3.0 and greater.

As was your formula -- it's "Monday" based.

I've used your padding concept for text conversion at the end. I normally leave it in numeric form and convert to text only when I need to combine with other text, as is done in the example below.

I've tried to keep this fairly efficient (I think I might be able to improve on the WeekOfYear_Gross variable formula)

REM { routine to figure out the week of the year a given date falls into --- for those applications that require a 53 week year};
REM { (i.e. those applications where the last week of the year is the first few days of the week that};
REM {    splits across a year end boundary};
REM { it's also true that the first week of the year is defined as the last days of the week that splits across a year end boundary.};
REM {   Its actually possible to get 54 week years by this definition!};

REM { Set the below Variable (SourceDate) to the value of the field that contains the date we will work on};

SourceDate := CompletedOnDist;

REM {First fugure out what the first day of the year in question is.};

FirstOfYear := @Date(@Year(SourceDate); 1; 1);
FirstDayNum_SundayBased := @Weekday(FirstOfYear);
FirstDayNum_MondayBased := @If(FirstDayNum_SundayBased = 1; 7;
FirstDayNum_SundayBased -1);

REM {Then get the week of the year for this date};
WeekOfYear_Gross := @Integer(@Integer(((@Date(SourceDate) - FirstOfYear) / (86400)) + 1) / 7) +1;

REM {Then adjust the week because the first day of they year may not fall on Monday};

DayOfWeek := @Weekday(SourceDate);
WeekOfYearNum := @If(DayOfWeek >= FirstDayNum_MondayBased;
WeekOfYear_Gross; WeekOfYear_Gross + 1);

Pad := @If(WeekOfYearNum < 10; "0"; ""); "Week " + Pad + @Text(WeekOfYearNum)

Stewart Clow (SCLOW@uk.ibm.com) modified Bill Westerly's formula to start weeks on Monday (the UK standard) instead of Sunday (the US standard):

REM { Returns the days at the start of the year up to Sunday as Week 1. Weeks start on Monday. FYI: 1984 is 54 weeks!
i.e. always returns week number for current year, rather than ISO week which can be week number for previous/next year. }

SourceDate := @Date(2009; 1; 11);

Jan1 := @Date(@Year(SourceDate); 1; 1);

DaysSinceJan1 := 1 + (SourceDate - Jan1) / 86400;
Jan1Weekday_SundayIs1 := @Weekday(Jan1);

Jan1Weekday_MondayIs1 := @If(Jan1Weekday_SundayIs1 = 1; 7; Jan1Weekday_SundayIs1 - 1);

WeekNum := @Integer((5 + DaysSinceJan1 + Jan1Weekday_MondayIs1) / 7);

PadChar := @If(WeekNum < 10; "0"; "");

"Week " + PadChar + @Text(WeekNum)

What Are Domino's Field Size Limits?
You can find the answers in Mike Woolsey and Ben Langhinrichs' Domino Size Limits page.

How do you get the HTML for a Rich Text field?
Thanks to Mark Vincenzes:

This URL will give you the HTML for a specific field so you don't have to parse an HTML page for it:
/database.nsf/view-unid/doc-unid/ItemName?OpenField
However, the content may be slightly different because OpenField runs in a different context than viewing an entire document.


How do you enable Java 5 (1.5) support in Notes 8?
Java 5 targetting is disabled in Domino Designer by default for backwards compatibility.
To enable this so that you can use Java 5 in your Notes agents and compile them, you have to add this to your notes.ini:

JavaCompilerTarget=1.5
Note that the Domino notes.jar file has not been updated to return Java 5 collections yet.


How do you disable NSD so exceptions go to Visual Studio?
If you add
APIDeveloper=1
to your Notes client's notes.ini, NSD will be disabled and the current JIT (Just In Time) debugger (usually Visual Studio) will be invoked.

You can also do "nsd -detach" if you're running Domino 8.x and above which uses a Windows service for NSD.


Why does my C API program crash when running on 64-bit Windows?

From Daniel Nashed:
Domino 7.0.2+ supports Windows 2003 64bit and can leverage more than 2 GB memory for local + shared memory.
What is still not widely known among ISVs is that you need to link your applications in Visual Studio with a new flag called /LARGEADDRESSAWARE. The flag allows a program to use more than 2 GB of memory (shared + local). Without this flag an application crashes when the 2 GB memory limit is reached. The Notes API samples up to 8.5 don't use this flag and they should.

What causes "Entry Not Found In Index" Errors?
This is generally caused by @DbLookup/@DbColumn on a view and the lookup key is not found.
However, it can also be caused by a save/replication conflict in the same view used for the lookups. If this is true, you can add "(!@IsAvailable($Conflict))" to the view selection formula to exclude conflicts.
It can also be caused by the view setting "Generate Unique Keys in Index for ODBC" if there's a replication conflict in the same view. In this case, you'll get an error if you try to open the view but you don't see any formulas or events that are doing any lookups.


How do you open a File Dialog in LotusScript?
Use the OpenFileDialog and SaveFileDialog methods in the NotesUIWorkspace class.

How do you edit a rich text field in an open document and redisplay it?
From Andre Guirard:

Dim wksp As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument, uidocNew As NotesUIDocument
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Dim strFieldname As String

Set uidoc = wksp.CurrentDocument
uidoc.Refresh True ' do this if the rich text field is editable, to get the current contents in case user has modified them.
Set doc = uidoc.Document �' get the back-end document for the document open on screen.
strFieldname = uidoc.CurrentField ' remember the current field if any
Set rti = doc.GetFirstItem("fieldname") ' insert your fieldname here, generally "Body"

' Make your rich text changes here, for instance:
Call rti.AddNewLine(1, True)
Call rti.AppendText(Now & ": log entry.")
If session.NotesBuildVersion >= 190 Then
rti.Update ' ND6 only
Else
Call doc.ComputeWithForm(True, False) ' caution, as this may erase some field values if you have @Db functions in formulas.
End If

doc.SaveOptions = "0" ' make it possible to close the document without a "do you want to save" prompt. If this is a mail-in doc you may need to set MailOptions="0" also to avoid being prompted.
Call uidoc.Close
Set uidocNew = wksp.EditDocument(True, doc, , , , True)
Delete uidoc
uidocNew.Document.RemoveItem("SaveOptions")
If strFieldname <> "" Then uidocNew.GotoField(strFieldname) ' return focus to field that was current before.

Note: this will cause Queryclose, Queryopen, Postopen (and so on) form events to trigger. Also, uidoc.Refresh will execute computed field formulas and input validations, so you should write the validation formulas to not return @Failure unless @IsDocBeingSaved | @IsDocBeingSent is true.


How do you find out if there is default view?
From Jens Winkelmann:


Dim docDefault As NotesDocument
Set docDefault = db.GetDocumentByID("FFFF0008")
If docDefault is Nothing then
'// default view does not exist else
'// default view exist end if


Notes Related Web Sites

Lotus' Notes Knowledgebase can be queried here. This is a great place to search for known bugs and workarounds that Lotus recommends.

These are all Domino Discussions:
* Lotus Domino Discussion
* Lotus Japan Notes Dicussion

Other Sites from Lotus and Iris Associates:
* Lotus Domino Wiki
* Lotus Development Corp. Home Page
* Lotus' Developer Central
* Notes.ini Settings

Other good Notes web sites:
* XPages Info site
* Frank Cseh's Notes Page
* European Notes Page
* Rose Kelleher's (a great book author) Notes Stuff
* Notes Design & Development
* Lotus Notes Job Listings
* E-Pro Mag
* Notesnet.Com
* Domino Security news
* Domilock (Domino web security checking tool)
* Breaking Par (Domino web hosting and free code snippets)
* Emie's Notes Links
* DRCC Notes.ini Reference
* SearchDomino
* Notes WikiFAQ
* Domiclipse (lets you write/debug Java agents using Eclipse)
* Open Source Quickplace Templates from SNAPPS
* Domingo (Java Notes API w/o needing recycle calls)
* Ext.ND (Web 2.0 extensions for Domino)
* Lotus Notes is Cool
* XPage Sample Apps and Controls