Validate RichtText item in a new document before save (in LotusScript)

I need to validate (check) if a richtextitem field is empty or not before saving it, in LotusScript.

As far as I’ve documented myself and tested several solution. It seems that this field doesn’t exist before saving it.

I tried to create a blank richtextitem in postopen , but on querysave it still be blank even if I put an attachment.

Any possible workaround?

Thanks.

Gemma

Subject: Not really :frowning:

In the past I’ve had to save the doc, get the form, interrogate the rtitems in that, and either keep or purge the docClumsy

Subject: An now …

How do you do it now ?

Subject: I don’t

It’s too clumsy

Subject: Solved

I Really don’t understand what you are talking about nor if you are trying to help or not.Nevertherless I solve with the following code on QuerySave action:

If Source.Document.fieldtocheck=" " Then

Call source.Refresh(True)

Dim rtitem As NotesRichTextItem

Set rtitem = source.Document.GetFirstItem( “attachment1” )

NotesEmbeddedObjectArray = rtitem.EmbeddedObjects

If Isempty ( NotesEmbeddedObjectArray ) Then

Messagebox “Please enter an attachment in field attachment1”

continue=False

Exit Sub

End If

I think that refresh do the trick.

Thanks

Gemma

End If

Subject: Suggestion…

My recommendation is to not use extended notation when addressing fields in the NotesDocument object. The GetItemValue() method is better for several reasons. It is slightly faster, according to what I understand, and it also prevent the code from breaking if a new method or property is added to the class in future versions of Notes.

You can also shorten MessageBox() to MsgBox()… :slight_smile: