Domino Code Fragment

Code Name*
How to Use the LotusScript NotesItem CopyItem Method
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.139.90.131
Description*
How to Use the LotusScript NotesItem CopyItem Method
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Note : This script could also be used in a form action.
Files/Graphics attachments (if applicable): Code:
Problem:
How is the NotesItem CopyItem method used?


Solution:
Below is an example of how to use the CopyItem method of the LotusScript NotesItem class. In
order to try it, follow the steps outlined below:


IMPORTANT NOTE: The following is a sample script, provided only to illustrate one way to
approach this issue. In order for this example to perform as intended, the script must be

laid out exactly as indicated below. Notes Support will not be able to customize this script
for a customer's own configuration.

1. Create a new form.
2. Add two editable text fields to the form named "A" and "B".
3. Add a button to the form.
4. Place the script below in the click event of this button.


Sub Click (Source As Button)

Dim session As New notessession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim itemA As NotesItem
Dim itemB As NotesItem
Dim i As Integer


Set db= session.currentdatabase
Set collection = db.UnprocessedDocuments
For i = 1 To collection.Count
Set doc = collection.GetNthDocument( i )
Set itemA = doc.GetFirstItem( "A" )
Set itemB = doc.GetFirstItem( "B" )
Call itemB.Remove
Call doc.CopyItem( itemA, "B" )
Call itemA.Remove
Call doc.save(True,False)
Next


End Sub

5. In order to test this form, place a value in the field "A" and click on the button.
The value will be copied into field "B".