Manage Learn to apply best practices and optimize your operations.

Force Saving UI Document Through Action for Check Attchment in Rich Text

On some occasions, you want to force users to Save UI-document by pressing some button to check documents.

I was faced this occasion to check if some Rich-Text fields contains attachment files, and check their sizes and extensions. The files that attached last time cannot handle(even see) in back-end class(notesDocument)until UI documents is saved.

I solved this problem by using this code and "SaveOptions" field.

If you use "SaveOptions" field only, user can close UI-document accidentally by pressing [ESC], and avoiding this, you must create some validating-field, set some value in this field in actions, and that is not smart.

This code is used for Form-Action-script only, but I think it's very useful.


Form has "SaveOptions" field, text, editable, keyword "1" or "0".

(Form Globals)
'Check if action button is pressed. True or False
%Include "lsconst.lss"
Dim ButtonPressed As Variant

(PostOpen)
'Initialize variant above
ButtonPressed = False

(QuerySave)
'Check if button pressed If Not ButtonPressed then
Msgbox "You must press 'Save' button for save this document.",
MB_OK+MB_ICONSTOP, "Save Notify"
Continue = False
End If

(Some Form-Action button)
Dim workspace As NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim note As NotesDocument
Set uidoc = workspace.CurrentDocument

On Error GoTo ErrorHandler

'button is pressed
ButtonPressed = True

'Refresh UI-document without save
Call uidoc.FieldSetText("SaveOptions", "0")
Call uidoc.Save

'Get backend note
Set note = uidoc.Document

'Code some checks.
'e.g. I wrote here to check richtext has embedded items.
' 1.Allow only file-attachment, deny Object/Object Link,
' 2.Allow only BMP files.
Dim rtitem As Variant
Dim objs as Variant
Set rtitem = note.GetFirstItem("Body")
If rtitem.Type = RICHTEXT Then
Set objs = rtitem.EmbeddedObjects
If Not IsEmpty(objs)
Forall obj In Objs
If obj.Type <> EMBED_ATTACHMENT Then
Msgbox "You can attach only files in this field."
Goto ErrorHandle
End If
If UCase(Right(Obj.Name, 3)) <> "BMP" Then
Msgbox "You can attach only BMP files in this field."
Goto ErrorHandle
End If
End Forall
End If
End If

'Save backend note
Call note.Save(True, True)

'button check clear
ErrorHandler:
ButtonPressed = False

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-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