FindFirstElement(RTELEM_TYPE_TABLE) not always working

We have a rather large instalment base of a Notes application to publish webpages. Documents are created in Notes and viewed in a web browser.

From a user perspective it is quiet normal to select content from a website and paste it in Notes. Sometimes the number of nested (more: nasty) tables get’s too large and the document can not be opened anymore in Notes.

I am no expert in rich text but there seem to be some LotusScript methods available to read/write to rich text. For example FindFirstElement:

Moves the current position to the first element of a specified type in a rich text item.

You can supply a parameter, the type of element you are looking for. In my case this would be RTELEM_TYPE_TABLE

So my plan was to navigate through the whole rich text, count the number of  tables, present a dialogue to the user and ask which table(s) may be deleted (in order of appearance in the rich text).

So without removing the complete rich text the user has at least a way to re-cover parts of the document (I notice attachments do not get deleted when calling the remove method on a NotesRichTextTable, as a remove method on a NotesRichTextItem would do).

You can read more details in the Designer help. Look for:

NotesRichTextTable class > Remove method

All nice but during test I noticed some odd behaviour:

  • The method initially could not find ANY table in the rich text:

Messagebox “Body item does not contain a table,”,, “Error”

  • After I attached a file in the table the method seem to be able to discover tables.
  • When I copied the agent from one application to another application it seems to have lost its ability (again) to find elements in rich text . The step to attach a file in a table does not work here.

I also noticed that the method described in previous versions was called getfirstelement, this seems to be renamed in later versions (I am working with 8.5.2).

So I am left in doubt. Surely this is not something I can offer as a function to try to recover rich text.

  • Do you have an alternative approach you can recommend?
About these ads

Born in Holland, current country of residence is Sweden. IBM Notes Consultant since 1997. Main focus is Xpages development. Other interests: computers, motorcycles, music (bass guitar) & cooking.

Tagged with: ,
Posted in LotusScript
2 comments on “FindFirstElement(RTELEM_TYPE_TABLE) not always working
  1. I have found that in cases where LotusScript fails, calling the Notes C API from LotusScript will save you. You could also try exporting, modifying and then reimporting DXL but I have found this to have its own problems.

  2. Bill Hanson says:

    RE:”The method initially could not find ANY table in the rich text”

    It sounds to me like the ‘RichText’ was initially stored as ‘MIME’. I thought that LotusScript automatically converted MIME to RichText unless you explicitly set NotesSession.ConvertMime to False, but you may need to verify this.

    RE:”After I attached a file in the table the method seem to be able to discover tables.”

    Once you modify a RichTextItem that contains MIME, Notes automatically converts it to RichText, so this supports my guess that the note first contained MIME, which was then converted to Notes RichText when you modified it.

    You may need 2 bits of code: 1 for MIME and another for Notes RichText. You should look at the following methods & classes to get started: NotesSession.ConvertMime, NotesDocument.GetMIMEEntity, NotesMIMEEntity, NotesMimeHeader.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Introduction
I am Patrick Kwinten. I am a IBM Notes Domino Product Specialist since 1996. With this blog I am trying to give my contribution to the community.
.
OpenNTF
Follow my projects on OpenNTF. Below are some examples:

Categories
RSS Feed
Follow

Get every new post delivered to your Inbox.

Join 201 other followers

%d bloggers like this: