Getting Field Values in LS

Hi all,

Am I missing something. I have scoured the Help files, but cannot find anything that just allows you to get the values in a field on the current document.

I would like to get a field that may have several names.

I would like to then select the first name and run some code, then go onto the next name etc.

Please could somebody help.

Subject: Getting Field Values in LS

You can use GetFieldText

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim names As String

Dim name as String

Set uidoc = workspace.CurrentDocument

names = uidoc.FieldGetText( “FieldName” )

’ names will have all values seperated by what u have selected for seperation

Eg: if u have used “,” as a seperator then

names = names+“,”

name = StrLeft(names, “,”)

If name <> “” then

while name <> “”

names =StrRight(names , “,”)

'Here goes the processing for use name

name = StrLeft(names, “,”)

wend

End IF

HTH

Keshava

Subject: RE: Getting Field Values in LS

Hi Keshava,

I have so far managed to put together this code.

But I would have expected the code to have generated 2 documents as there are 2 values in the field AlarmDialog

Error - Type mismatch

Sub Click(Source As Button)

'Set Dimensions

Dim session As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim db As NotesDatabase

Dim doc2 As NotesDocument

Dim item As NotesItem

'Get Current Document to work on

Dim uidoc As NotesUIDocument	

Dim doc As NotesDocument	



Set uidoc = workspace.CurrentDocument

Set doc = uidoc.Document

'Save current document

Call uidoc.Save

'Get Values in Field

Dim names As String

Dim altnames As String



names = doc.FieldGetText( "AlarmDialog" )

names = names+","

altnames = Strleft(names, ",")



If altnames <> "" Then

	While altnames <> ""

		names =Strright(names , ",")

		

		altnames = Strleft(names, ",")

'*************************************************

'This is where I woulld use the name to lookup their mailfile & server

		' Then create the doc in their database

'*************************************************

		Set db = session.GetDatabase("Spinoza" , "mail\pthomas.nsf")

		

		'Create mini-doc

		Set doc2 = New NotesDocument(db)

		Set item = doc.GetFirstItem("$Alarm")

		Call item.CopyItemToDocument(doc2, "$Alarm")

		Set item = doc.GetFirstItem("$AlarmOffset")

		Call item.CopyItemToDocument(doc2, "$AlarmOffset")

		Set item = doc.GetFirstItem("CalendarDateTime")

		Call item.CopyItemToDocument(doc2, "CalendarDateTime")

		Set item = doc.GetFirstItem("Subject")

		Call item.CopyItemToDocument(doc2, "Subject")

'Save and move mini-doc to folder

		Call doc2.Save(True , False , True)

		Call doc2.PutInFolder ("($Alarms)")

'Close original document

		Call uidoc.Close

		

	Wend

End If

End Sub

Subject: RE: Getting Field Values in LS

You are mixing up classes from the UI with backend classes. For example, your codenames = doc.FieldGetText(“AlarmDialog”) will throw an error because doc is declared as a backend document and FieldGetText is a UI document method.

The easiest way to loop through all of the values in a field is to use something like

forall n in doc.AlarmDialog

'Do whatever you need to do with each value

end forall

Check out the Notes Designer Help db for more information about the UI classes, backend classes, and the Forall loop

Subject: Getting Field Values in LS

how about…

set item = doc.getfirstitem(“YourField”)

forall singleentry in item.values

’ do something with the single entry

print singleentry

End Forall

Subject: RE: Getting Field Values in LS

When running in an agent it gives an error ‘Object Variable not set’

Sub Initialize

Dim session As New NotesSession

Dim workspace As New NotesUIWorkspace

Dim db As NotesDatabase

Dim item As NotesItem

'Get Current Document to work on

Dim uidoc As NotesUIDocument	

Dim doc As NotesDocument	



Set item = doc.getfirstitem("AlarmDialog")

Forall singleentry In item.values

’ do something with the single entry

	Print singleentry

End Forall

End Sub

Subject: RE: Getting Field Values in LS

You need to Set doc = uidoc.Document before the getfirstitem operation. Then I find using the Notes Document in Script is a lot easier. If you are new to Notes Development try these two books 1. Lotus Notes and Domino 6 Programming Bible by Brian Benz and Rocky Oliver 2. Lotus Notes and Domino 6 Development by Steven Kern I find these books a great help in the past

Subject: Getting Field Values in LS

Have a look at the fields property of the NotesForm class to cycle through all fields on a given form.

HTH

Subject: RE: Getting Field Values in LS

I am only a beginner. I have had a look but come around the the same problem of creating some code to loop through the values in the field.

Subject: look at notesdocument.getitemvalue