当前位置: 代码迷 >> Lotus >> 怎么判断一个attachment类型的域是否为空
  详细解决方案

怎么判断一个attachment类型的域是否为空

热度:72   发布时间:2016-05-05 06:58:16.0
如何判断一个attachment类型的域是否为空?
因为表单中有两个放附件的域A和B,无法用hasEmbedded来判断B是否有附件。
请大神指点一下其他方法。我只需要判断域B是否有附件,但是域A会干扰。

往一个RichText类型的域里放文档链接(Copy as a document link)。怎么判断这个域是不是空?

两个问题,感谢了先!

------解决方案--------------------
目前没有完美的办法,
1) 如果可以先保存文档,那你可以先保存文档(uidoc.Save),然后重新打开就可以对单个RTF字段内容进行判断:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkSpace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim strUNID As String
Dim rtfItem As Variant
Dim bFind As Boolean

Set db = session.CurrentDatabase
Set uidoc=ws.CurrentDocument
Call uidoc.Save()
strUNID = uidoc.Document.UniversalID
Call uidoc.Close()
Set doc=db.getDocumentByUNID(strUNID )
Set uidoc=ws.EditDocument(True,doc)
Set doc=uidoc.Document
Set rtfItem =doc.GetFistItem("Your RTF Item Name")
If Not Isempty(rtfItem.EmbeddedObjects) Then
bFind=False
Forall o In rtfItem.EmbeddedObjects
If o.Type=EMBED_ATTACHMENT Then
bFind=True
End If
End Forall
If Not bFind Then
Msgbox "Has Not any Attachment!"
Else
Msgbox "Has Attachment!"
End If
Else
Msgbox "Has Not any Attachment!"
End If

链接的判断只要将那个EMBED_ATTACHMENT换成EMBED_OBJECTLINK,具体参考:
类NotesRichTextItem的EmbeddedObjects属性和类NotesEmbeddedObject的Type属性

1) 如果判断要求不可以保存文档,那只好做个近似的检查无法检查RTF具体写了什么,只能知道它里面有没有东西:
Function CheckRTFField(uidoc As NotesUIDocument, strFieldName As String, strErrorMsg As String) As Boolean
On Error Goto ErrorHandle
CheckRTFField=True
If Not uidoc.EditMode Then
uidoc.EditMode=True
End If
Call uidoc.GotoField(strFieldName)
Call uidoc.SelectAll()
Call uidoc.DeselectAll()
Exit Function
ErrorHandle:
If Err=4407 Then
Msgbox "Error: "+strErrorMsg
CheckRTFField=False
Exit Function
Else
Resume Next
End If
End Function