Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1592
  • Last Modified:

I have a lotusscript agent that retrieves form fields on a form but i realized it does not get the hidden fields on the form, How can i get hidden fields and avoid richtextfields during this retrieval

Hi,

I am getting all the fields on a form into an array with the code below

ForAll Field In NotesForm.Fields
		strArray(i)=CStr(Field)
		i=i+1
End ForAll

Open in new window


but i realized that i does not get hidden fields and also it gets  the fields that are richtext field like attachment fields..

is there a way to prevent richtext fields in the array and include hidden fields programatically?

thank you...
0
nicedone
Asked:
nicedone
  • 6
  • 3
  • 2
1 Solution
 
larsberntropCommented:
1.  Use NotesDocument.Fields.
2. Check the NotesItem for its Type, if Type = 1 then it is a rich text item.
0
 
ThomasMcA2Commented:
Actually, it's notesDocument.Items. Try this:

Forall Items in notesDocument.Items
   If Items.Type = 1280 then
     ' you found a text item
   End If
End Forall

Open in new window

0
 
nicedoneAuthor Commented:
@ThomasMcA2
As far as i know NotesDocument.Items brings alot of unnecessary stuff but i just want the fields to be taken into account so

Items.type=1280

would solve my problem you think?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ThomasMcA2Commented:
That won't do what you want because even "internal" fields have item.type = text (1280).

I don't know of a way to get only the fields on the form, yet exclude rich text, attachments, and other miscellaneous types. Maybe Sjef has an idea.

BTW, since notesForm.Fields is an array of strings, your original loop can be replaced with this single line:

strArray = notesForm.Fields
0
 
nicedoneAuthor Commented:
BTW;
In the below code i could not even get the item to a string array somehow because i need to write it to text file even that did not work so i probably better off the first way NotesForm.Fields i guess if you can point what is wrong below i wd appreciate though
i think items(0) has some issues but i tried items too it all did not work when passing to array

ForAll items In doc.items
		If items.type=1280 Then
			strArray(i)=arr+"(" + CStr(i) +")="  +CStr(items(0))
			WritefrmFields(CStr(items(0)) +"  " +CStr(fieldCount) +"  "+i)
			i=i-1
			x=x+1
		End If
	End ForAll

Open in new window

0
 
larsberntropCommented:
When using ForAll statements I usually copy the looping Variant variable to a Notesitem variable for added ease of use like so:
Dim it as NotesItem
ForAll items In doc.items
	Set it = items
	If it.Type=1280 Then
		strArray(i)=arr+"(" + CStr(i) +")="  +CStr(it(0))
		WritefrmFields(CStr(it(0)) +"  " +CStr(fieldCount) +"  "+i)
		i=i-1
		x=x+1
	End If
End ForAll

Open in new window

This has the benefit of prompting you for object members and methods. It also immedeately flags your use of items(0) as a syntax error, which the editor cannot do earlier because items is a Variant. Also help works better etc.

Second, to better help you, you need to provide more context.  What exactly do you want to accomplish, and why? Do you want a list of fields, or the contents of those fields?
0
 
nicedoneAuthor Commented:
Ok let me be more precise then,

what i want is to migrate data from lotus notes to excel..

for that purpose to export to excel i need to identify what fields i want to export to excel

but there is not just 1 database and 1 form, i need to do this on hundreds of databases and forms so i want a generic way to export to excel ,by default get all the fields on the form

so i can give the form name and database name and automatically without going and checking inside the form agent can give me the list of fields on that form ,later on from those fields i can get the values then do the export...

but as you wd understand i already dont need richtext fields or attachments since i dont want to export them.

NotesForm.Fields works fine but it gives me richtext fields too... Actually i could have ignored this but NotesForm.Fields do not get the hidden fields on the form too which ruins everything because then i might miss out an important data holding hidden field then i need to check inside the form

So i need a generic way to export all fields on a form to excel including just the text fields...
0
 
nicedoneAuthor Commented:
and by the way in your code above i get

Illegal parenthesized referance:IT

error

but the parenthesizes look OK?
	Dim it As NotesItem
	ForAll items In doc.items
		Set it = items
		If it.Type=1280 Then
			strArray(x)=CStr(it(0))
			i=i-1
			x=x+1
		End If
	End ForAll 

Open in new window

0
 
larsberntropCommented:
Of course you get an error.  That is the point of using an actual NotesItem object instead of a Variant, so that the LotusScript compiler can detect more errors, and to ease the code writing.

Since i have no idea what you are trying to accomplich with items(0), here is a suggestion:

Dim it as NotesItem, numItems As Integer
numItems = UBound(doc.Items)
ReDim strArray(numItems)
ForAll items In doc.items
	Set it = items
	If it.Type=1280 Then
		strArray(i) = arr + "(" & i & ")=" & it.Text
		WritefrmFields(it.Name & "  " & fieldCount & "  " & i)
		i=i+1
		x=x+1
	End If
End ForAll

Open in new window


You might want to include a computed when composed multivalue text field on a form, filled with the relevant to be exported to Excel item names.

then you would code:

Dim it as NotesItem, numItems As Integer, vFields as variant
vFields = doc.GetItemvalue("fieldsForExport")

numItems = UBound(vFields)
ReDim strArray(numItems)
For i = 0 to numItems
	Set it = doc.GetFirstItem(vFields(i))
	' If it.Type=1280 Then ' if type is text bit it.Text works for all fields, so...
	strArray(i) = arr + "(" & i & ")=" & it.Text
	WritefrmFields(it.Name & "  " & fieldCount & "  " & i)
	' End If
Next

Open in new window

Note: this works for single value fields.  For multivalue fields, you need to devise a different strategy.  Caveat: I have no idea what fieldcount is doing in this bit of code. nor what WritefrmFields does.
0
 
nicedoneAuthor Commented:
Ok thank you very much i will be able to try this code later and let you know..by the way fieldcount is number of fields that i am exporting... and WritefrmFields is writing those fields to a text file thats it.
0
 
nicedoneAuthor Commented:
tnx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now