Hi All,
I have a view which shows documents created with a from named Main. In this Main form, there is a Rich Text field which is named DVPR. Now, if this field contains attachment and this attachment is an Excel attachment, then the column in the view should indicate that attachment is present in the DVPR field otherwise column should indicate that no attachment is present.
How this can be achieved?
Please let me know.
Thanks in advance.
Aditya.
Subject: Attachment Present?
@If(@Contains(@LowerCase(@AttachmentNames); “.xls”); “Excel Sheet”; “Others”);
Try this and modify according to your requirement.
Subject: RE: Attachment Present?
Thanks for the reply Gayatri…I tried to modify the code u gave but no success…:(It will work only when the DVPR field as wel as any other RT field in the document contains Excel sheet. It wont work if DVPR field do not contain Excel sheet and any other field contains Excel sheet.
any suggestions…
Subject: RE: Attachment Present?
Correct @Attachment name works on full document instead of one field.
You will need to use the Lotus Script and set a field on your form indicating the name of your attachment then doing your view calculation from there.
Here’s is a snippet of some code from LN Help File and I added a couple that should get you started:
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
nam = o.name
yourfieldnamehere = nam
Call doc.Save( True, True )
End If
End Forall
End If
You will have to declare and set some items but you should be able to figure it out from here.
Once you have the new field set showing the name then you can use that to calculate your view column.
HTH
Teri
Subject: RE: Attachment Present?
Some one pls solve this problem…
Belwo is d code…
Sub Postopen(Source As Notesuiview)
'Variables for getting the handel of Backend
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
'Variables for getting the handel of the attachment.
Dim ntitem As NotesItem
Dim rtitem As NotesRichTextItem
Dim allembed As Variant
Dim ob As NotesEmbeddedObject
Dim rtnav As NotesRichTextNavigator
Dim count As Integer
Set db=sess.CurrentDatabase
Set view=db.GetView("RCN_Num")
Set doc=view.GetFirstDocument
Dim formname As String
formname=doc.form(0)
While Not doc Is Nothing
If formname="RCN" Then
'Msgbox doc.RCNNumber(0)
Set ntitem = doc.GetFirstItem("DVPR")
If (ntitem.type = RICHTEXT) Then
Set rtitem = ntitem
allembed = rtitem.EmbeddedObjects
Set rtnav = rtitem.CreateNavigator
If Isempty(allembed) Then
doc.format="No Attachment Found"
Set doc=view.GetNextDocument(doc)
formname=doc.form(0)
Else
'code for finding out the format as attachment is present
Set ob = rtnav.GetFirstElement(RTELEM_TYPE_FILEATTACHMENT)
count = 0
While Not (ob Is Nothing)
Set ob = rtnav.GetNextElement(RTELEM_TYPE_FILEATTACHMENT,count)
count = count + 1
Wend
Redim obname(count) As String
While Not count = 0
Set obnam = rtnav.GetNthElement( RTELEM_TYPE_FILEATTACHMENT, count)
obname(count) = obnam.Name
count = count - 1
Wend
Dim substring_1 As String
subString_1 = Right$(obname(0),4)
If subString_1=".xls" Then
doc.format="Excel"
Else
doc.format="Not Present"
End If
End If
End If
Set doc=view.GetNextDocument(doc)
formname=doc.form(0)
Else
'Msgbox doc.RCNNumber(0)
Set ntitem = doc.GetFirstItem("DVPR_0")
If (ntitem.type = RICHTEXT) Then
Set rtitem = ntitem
allembed = rtitem.EmbeddedObjects
Set rtnav = rtitem.CreateNavigator
If Isempty(allembed) Then
doc.format="No Attachment Found."
Set doc=view.GetNextDocument(doc)
formname=doc.form(0)
Else
'code for finding out the format as attachment is present
Set ob = rtnav.GetFirstElement(RTELEM_TYPE_FILEATTACHMENT)
count = 0
While Not (ob Is Nothing)
Set ob = rtnav.GetNextElement(RTELEM_TYPE_FILEATTACHMENT,count)
count = count + 1
Wend
Redim obname(count) As String
While Not count = 0
Set obnam = rtnav.GetNthElement( RTELEM_TYPE_FILEATTACHMENT, count)
obname(count) = obnam.Name
count = count - 1
Wend
subString_1 = Right$(obname(0),4)
If subString_1=".xls" Then
doc.format="Excel"
Else
doc.format="Not Present"
End If
End If
End If
Set doc=view.GetNextDocument(doc)
formname=doc.form(0)
End If
Wend
End Sub
the field which needs to be updated (format) is not getting updated…what can be the problem…