We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Cycling through $Body form fields in LotusScript

evets27
evets27 asked
on
Medium Priority
1,914 Views
Last Modified: 2013-12-18
Hey All;
I'm a fairly advanced VB/VBA coder trying to write LotusScript to cycle through all the forms within a NSF database and read through each one's $Body field (or fields if there's more than one) to look for specific strings.  I've tried several different methods such as doc.FieldGetText( "$Body" ), but I only get errors like "Type Mismatch".  The online help file says "A Field object has no properties or methods" such as Field.Value; how can I read this value in code?

Thanks very much in advance!
Comment
Watch Question

$Body is a richtext field and it sometimes could have been signed .

Treat it as richtext and use GetFormattedText method to extract text values.

~Hemanth

Author

Commented:
Just to clarify too; I'm working with R5 not R6
Will do.

Commented:
Echoing Hemantha... but you also need to use a different object type.  Since you are using FieldGetText, you must be using a NotesUiDocument object, which is merely the "front end" -- an on-screen document DISPLAYED USING the form, not the form's design itself.  You want the form itself, which in R5, you can only treat as a NotesDocument and "go hunting" for it.  Otherwise, you have to resort to the C-level API.

Author

Commented:
Thanks for the input guys; I see I have a little to learn about Lotus!  I'm not sure what you mean exactly by 'going hunting'; are there specific functions I can use to do this?  For what I'm looking at I don't think I can invest the time in working with a C-level API; there really isn't an easy way, with the Lotus object model, to loop through and read these values??  When I view the Design Properties for the form it's all right there.  As far as 'front end' vs. back end, I don't really care HOW I get the results, as long as I can read through the $Body text and work with it in code.

Thanks again for responding!  Sorry if I'm being difficult here...

Commented:
In R5, there is no explicit mechanism for finding design objects.  If you go to the notes.net Sandbox, there is a tool called DBDesign that uses LotusScript to declare the external DLL functions for finding the deign elements.  Using VB, you could do the same.

Once you have the BACK END (NotesDocument) object, you can retrieve the NotesRichTextItem named $Body from it using NotesDocument.getFirstItem.  You can then get the text of the rich text $Body field via getFormattedText or via .Text.  Don't expect to be able to make changes to it, though.
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Sorry to be high-maintenance about this (I'll raise the point value of this question); but all of the documentation I'm seeing says "'...set value of doc..." without giving good examples of how to do it.  I've tried looping through the Forms collection using "Forall form In db.Forms" and that works all right; then I loop through the Fields collection to get the names of the fields.  But I can't get the values from there.  Can I get to the $Body value via the Forms collection or will I have to open it as a NotesDocument, then use getFirstItem > getFormattedText?  And I won't need to make form changes, just browsing through so if $Body is read-only that's no problem.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
If you have access to a Notes Designer, than this DB might be of help for you:

http://www-10.lotus.com/ldd/sandbox.nsf/e7425656e0c80508852567540065d7f9/f81067f94a1143f3852567d800660625

Peter
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.