Manage Learn to apply best practices and optimize your operations.

Validate rich text fields for attachments without saving the UI document

This tip describes how to validate rich text fields for attachments without saving the UI document.

Validation of rich text field on the UI poses a tricky situation, particularly when it is required to check if any attachments have been added to the field. This happens because the LotusScript doesn't get a handle to the embedded objects in a rich text field until the UI document is saved to the backend document. Thanks to the enhanced 'refresh' method of NotesUIDocument class in R5, this tricky problem can be solved with some simple code.

Here is the 'test' code and the steps to carry out the test...

  1. Add a button to a form that contains a rich text field named 'Body'
  2. Attach the following code to the button.
  3. Save the form and preview in Notes client.
  4. When you click on the button, it should pop-out a message indicating the number of attachments in the Body field.

Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument  
Set uidoc = ws.CurrentDocument
Set doc = uidoc.document
 
uidoc.refresh True  '<= here's the hero! The 'True' parameter 'transfers' all rich text items to the back-end document.
Dim rtitem As Variant
Dim embedObjs As Variant
 
Set rtitem = doc.getFirstItem("Body")
embedObjs = rtitem.embeddedObjects
 
Msgbox "There are " + Cstr(Ubound(embedObjs) + 1) + " attachments in 'Body' field"
  

Dig Deeper on Domino Resources - Part 6

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

Dim rtitem As Variant
Dim embedObjs As Variant
uidoc.refresh True
Set rtitem = doc.getFirstItem("rtfield")
embedObjs = rtitem.embeddedObjects
NombreCampo = "Descriptivo"
If Isarray( RTItem.EmbeddedObjects) Then

Else
Msgbox "El campo "+NombreCampo+ ", debe tener el respectivo adjunto... Por favor verifique. ", MB_OK + MB_ICONSTOP, "Validar adjuntos"
uidoc.GotoField("descriptivo")
continue = False
Exit Sub
End If

' Con esto validamos que el RT tenga almenos un adjunto
Cancel

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close