Manage Learn to apply best practices and optimize your operations.

RichText field validation

This piece of code checks and restricts users from attaching relevant attachments.

This piece of code checks and restricts users from attaching relevant attachments.
Only one and of type gif or jpg/jpeg in this case.

Note : SaveOptions need to be taken care !!
Sub Click(Source As Button)

	Dim workspace As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim rtitem As Variant
	Dim objName As String
	Dim objExtn As String
	Dim count1 As Integer
	count1 = 1
	'setting the doc to uidoc
	Set uidoc = workspace.CurrentDocument
	Set doc = uidoc.Document
               ' validation for other mandatory fields	
	If (	uidoc.FieldGetText("tName")="") Then
		Messagebox "Please enter Name",0,"Alert"
		Call uidoc.GotoField("tName")
		Exit Sub
	End If
	'. . . and so on
	'setting save options to '0'
	Call uidoc.reload
	Set rtitem = doc.GetFirstItem( "rtFoto" ) 
	'checking for whether anything has been attached or not
	If (rtitem.Type = RICHTEXT And Isarray( rtitem.EmbeddedObjects) ) Then
		Forall o In rtitem.EmbeddedObjects
			If ( o.Type = EMBED_ATTACHMENT ) Then
				'capturing the attachment name and number of attachements
				objName =
				count = count + 1
			End If
		End Forall
		var = workspace.Prompt(PROMPT_OK,"Alert","attach foto")
		Call uidoc.GotoField("rtFoto")
		Exit Sub
	End If
	'restricting the user to attach only one attachment
	If(count<> count1) Then
		var = workspace.Prompt(PROMPT_OK,"Alert","only one foto please")
		Call uidoc.GotoField("rtFoto")
		Exit Sub
	'restricting the user to attach only gif or jpg file

		objExtn = Strright( objName, "." )
		If  Not (objExtn = "gif"  Or  objExtn = "jpg" Or objExtn = "jpeg") Then
			var = workspace.Prompt(PROMPT_OK,"Alert","attach a 'gif' or a 'jpg' foto")
			Call uidoc.GotoField("rtFoto")
			Exit Sub
		End If
	End If
	'finally saving the document
End Sub

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials'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 ...