I never thought of having this silly problem.I have a rtf where I paste a jpg image(not attachment nor embedded object).
I need to select in a view only the docs that have an image in that rtf.
The selection formula doesn’t work (Select ImageBody != “”).
I created a field that computes the value of the rtf :
@If(ImageBody != “” ; “Yes” ; “No”), hoping to use that value in the selection formula.
That works in the neginning, when there’s nothing in the rtf(Flag’s value is “No”. It works when I paste the image too(Flag’s value is “Yes”). But when I delete the image, the field stays “Yes”.
I searched on rtitem, but I couldn’t find anything to help me.
Well, if IBM had added a RTELEM_TYPE_GRAPHIC type, you could have done this by running an agent using the NotesRichTextNavigator, but they didn’t. You have a few choices:
You can simply guess based on the size of the rich text field, if the graphic is all you are likely to have in there,
You can use DXL with the new DXL LotusScript classes to export the document to a stream and then look for JPEG’s, and save a flag on those documents,
You can use a third party product such as our Midas Rich Text LSX, and also save a flag. Midas would use code such as:
Private Function getvaluelength (doc As notesdocument, nameitem As String)As Long
'returns item value length
If Not doc.hasitem(nameitem) Then
getvaluelength = 0
Exit Function
End If
Dim db As notesdatabase
Set db = Me.note.parentdatabase
Dim netpath As String*1024
OSPathNetConstruct 0, db.server, db.filepath, netpath
Dim hDB As Long
NSFDbOpen netpath, hDB
If hDB = 0 Then
Error 20000, "wrong db handle"
Exit Function
End If
Dim hNT As Long
NSFNoteOpen hDB, Clng("&H" & doc.noteid), 0, hNT
If hNT = 0 Then
Error 20000, "wrong note handle"
Exit Function
End If
Dim iB As BlockID, vB As BlockID
Dim dt As Integer
Dim nv As Long
Dim p As Long
Dim n As Integer
NSFItemInfo hNT, nameitem, Len(nameitem), iB, dt, vB, nV
NSFNoteClose hNT
NSFDbClose hDB
getvaluelength = nV
End Function
I don’t believe there’s any way to do it just with formula language, but NotesRichTextItem.ValueLength property should let you determine whether there’s some content there – you’d have to store that information in a hidden field so that the view could use it. Just keep in mind if you write code in Querysave that you have to use NotesUIDocument.Refresh with an optional argument to get the up to date rich text value.