NotesNames in LotusScript

Just wanted to show how easy creating names, authors, and readers fields can be in LotusScript?

As always there are different ways to accomplish that. Here’s two of them.

1) Use New NotesItem:
Set item = new NotesItem(“SendTo”, sendToArray,NAMES) ‘ For other type use the SpecialType parameter with AUTHORS or READERS instead of NAMES depending on what you want to create.

This is useful if you want to do something more with the field/item.
Eg. Change some properties.

2) Using ReplaceItemValue
set item = doc.replaceItemValue(“SendTo”,sendToArray)

This will only create a text field item. We need to change it to an Names item.
item.isNames = true

This can be shortened since ReplaceItemValue returns a notes item:
doc.replaceItemValue(“SendTo”,sendToArray) .isNames = True

If you want it to be readers field or authors field do this.

doc.replaceItemValue(“SendTo”,sendToArray) .isReaders = True

doc.replaceItemValue(“SendTo”,sendToArray) .isAuthors = True

Personally I tend to use the shortened version since I find it easier to read. That is if I do not need the NotesItem further down in the code.

It saves me a dummy variable which may not be using further down in the code.
I do not like to set variables which are never used.

It’s like in a movie where you get to see a shotgun in the beginning of the film. You then sort of expect it to be used before the end.