Search This Blog

Friday, January 11, 2013

How to clear out Richtext field using either @commands or NotesUIDocuments method

Hi

Recently I worked on a simple task where I had to create a static table with different fields inside of table cells and with buttons [+] and [-] to display or hide table rows. When user clicked on [-] I had to clear out all fields from the row I was going to hide. There was a NotesRichText field among row fields.

This task looked very simple but when I started to work on [-] button I spent more time then I expected.

Let's imagine that you have some application with RichText field on the form and you need to clear it out without using back-end possibilities (because you do not want to make all those document reopening and other things to display changes immediately).

So you write something like this:


It works perfect.
But only with a text :-)

If you try it on attachment you will get a standard confirmation dialog from Notes


So, how can we get rid from it?

The trick I found is to replace @command([EditClear]) with @Command([EditInsertText]; " ");



Now it works perfect even with attachments.
You can do the same things using methods of NotesUIDocument class.

Lotus Powa!

4 comments:

  1. Ui, thank you! It saved a lot of time and prevented ugly solutions! :-)

    ReplyDelete
  2. Do you know any way to select and delete text using @Commands? For example, in a forwarded message I want to customize the forward header. I can get to here:
    @Command([EditGotoField];"Body");
    @Command([Editdown]);
    @Command([EditRight];"29");
    At which point I want to delete some text - say 7 characters to the right - and insert something else. The insert is easy with
    @Command([EditInsertText];"new stuff");
    but I can't find out how to delete the old stuff!

    ReplyDelete