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
1,394 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
  • 6
  • 3
  • 2
11 Comments
 
LVL 10

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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 10

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 10

Accepted Solution

by:
larsberntrop earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now