Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-14
11
Medium Priority
?
1,563 Views
Last Modified: 2013-12-18
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
Comment
Question by:nicedone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 
LVL 11

Expert Comment

by:larsberntrop
ID: 39165034
1.  Use NotesDocument.Fields.
2. Check the NotesItem for its Type, if Type = 1 then it is a rich text item.
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 39165718
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
 

Author Comment

by:nicedone
ID: 39165991
@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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 39166714
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
 

Author Comment

by:nicedone
ID: 39167312
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
 
LVL 11

Expert Comment

by:larsberntrop
ID: 39167491
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
 

Author Comment

by:nicedone
ID: 39167632
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
 

Author Comment

by:nicedone
ID: 39167655
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
 
LVL 11

Accepted Solution

by:
larsberntrop earned 2000 total points
ID: 39168608
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
 

Author Comment

by:nicedone
ID: 39169496
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
 

Author Closing Comment

by:nicedone
ID: 39171367
tnx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question