« Dell Technical Support | Main| What Are Your Parent's Views? »

Programmatically In-Line Editing Attachments

Tags: development

I recently wrote a small workflow application for one of our clients. The Notes app provides the workflow capabilities while the actual form is an Excel sheet which ist attached to a Notes Document.

Since some of the users kept hitting "open" instead of "edit" from the attachment's context menu, infobox, or menu (and were complaining that their changes got lost) my client asked me to help avoid this problem.

Unfortunately there is no programmatic way to start in-line-editing the attachment. The solution I found uses a simple API call as suggested in "How to Simulate User Keyboard Events in LotusScript Without Using SendKeys (user32.dll)" in the Lotus Software Knowledge Base. The function "keybd_event" in the Windows library "user32.dll" simulates keyboard events at the operating system level. So I only had to write some code in a button to put the cursor in the rich text field containing the attachment, select the attachment and select the menu entry "Attachment - Edit" using the correct key sequence (which happens to be ALT-T-E in English clients and ALT-H-ENTER-B in German clients).

Only the original document creator should be able to edit the attachment so I put it in a hidden controlled access section. But even users allowed to edit the attachment should not be allowed to remove the attachment or attach additional files to the field. To avoid that I wrote a short script in the Entering event of the richt text field which takes the cursor back to the previous field when it enters the field (Call uidocCurrent.GotoPrevField). To make the code working that is executed in my "edit attachment" button (put cursor in field, select all, call key sequence) I had to add a flag which was set in the button. That flag was checked in the Entering event and if it was set the cursor was allowed in the field. It might be a little confusing to the user to see an editable field and not to be able to enter it but I didn't see a better solution here. It would have been nice to just be able to change the access formula of the controlled access section on the fly but controlled access section formulas compute when the document is opened. Closing and re-opening the document was no option here.

This solution using the API call is nice and powerful but it also has some disadvantages. The first problem is that it only supports Windows clients (and the API function might not be available forever). In my case at least the platform is no problem since all the users are on Windows. A second disadvantage is that the keyboard combination depends on the client user interface and might also change in a future version of the Notes client.

To be able to support multiple languages I made the key combinations configurable in the database setup profile document. I used the list of virtual key codes on the MSDN site to provide a list of keys to select from. I would have preferred to let the user enter the required key sequence directly by redirecting the keyboard input but I didn't find a simple way of doing this.

Here is a screenshot of the dialog box I use to configure key sequences for different languages (sorry - german only, but you'll get the idea).

Screenshot of a german dialog box to configure language and key sequences

To find out the language of the user interface I am using the Notes.ini variable "UserInterface" (see Technote 1168965 ) which is available from Notes Client Version 6.0.1.


Using the API call is a nice way to do things in Notes if there is no programmatic way to do them. But I would much prefer to have access to some features through Notes native functions in a documented and reliable way.

Comments

Gravatar Image1 -

Gravatar Image2 - Hi
Great coding I must say, can you please provide me with the code or a sample database.

Take care

Just remove the xxx_ from the e-mail address

Gravatar Image3 - i liked the fuctionality of edit attachment ,could pls send me the code for.highly appericiate your skills

Gravatar Image4 - Hi Jens,

I'm very interested in this code. Could you, please, send me it.

Thanks in advance

Gravatar Image5 - Hi, Can you please send me this code??? Or tell me where it is published? Thanks, will get me out of a big hole!

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Search

Calendar

MiscLinks

We Use Ytria Lotus Notes Tools For Faster Notes Development and Better Domino Administration

Tags

Site Info