我被要求在前任设置的莲花笔记数据库的表单上设置电子邮件操作按钮。问题是表单从嵌入视图中提取数据,因此当我通过电子邮件发送文档时,嵌入视图中的数据将丢失。有没有办法从文档中的嵌入视图中保存数据,然后可以通过电子邮件发送。 Lotus Notes版本为9。
答案 0 :(得分:1)
正如Rich所说,您无法邮寄文档并包含存储在其他文档中的通过嵌入视图查看的数据。
您可以做的是实际读取数据并将其存储在您邮寄的文档中。我在这里的博客文章中描述了一种方法: http://blog.texasswede.com/dynamic-tables-in-classic-notes/
您所做的是创建一个小表单,表示一行数据的样子。把字段放在那里,添加格式等。我称之为“行模板”:
在主窗体(“目标窗体”)上添加一个新的富文本字段,稍后您将显示嵌入的数据。我通常将该字段设置为尽可能小,使用Arial 1pt格式化它。在下面的示例中,我有一些隐藏(红色)字段和一个表(与模板行形式中的表格相同的宽度)作为标题行。在你的情况下,你可能有更多的字段,但这并不重要。
然后在主窗体中添加代码(由文档使用),用于标识要包含的所有文档(嵌入视图当前显示的文档)并循环显示这些文档。 对于每个文档,您将获得要显示的值,使用行模板表单将它们放入新的内存中文档,将该表单呈现为目标文档上的富文本字段并丢弃内存中的文档。重复,直到您处理完所有文档。
我经常将代码放在QueryOpen事件中,因此在文档打开之前执行。主要原因是我不喜欢嵌入式视图,它们对用户没有吸引力,而且它们的灵活性远远低于我的技术。这是我使用的代码:
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, _
Continue As Variant)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim col As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim entrydoc As NotesDocument
Dim thisdoc As NotesDocument
Dim datafield As NotesRichTextItem
Dim templatedata As NotesRichTextItem
Dim entrydata As NotesRichTextItem
Dim doclink As NotesRichTextItem
Dim template As NotesDocument
Dim parentunid As String
If source.IsNewDoc Then
Exit Sub ' Exit if new document, we do not have a ParentUNID or entries yet
End If
Set thisdoc = source.Document
Set datafield = New NotesRichTextItem(thisdoc,"Data")
parentunid = thisdoc.GetItemValue("ParentUNID")(0)
Set db = session.CurrentDatabase
Set view = db.GetView("(LookupEntry)")
Set col = view.GetAllEntriesByKey(parentunid,True)
Call thisdoc.ReplaceItemvalue("EntryCount",Cstr(col.Count))
Set entry = col.GetFirstEntry
If Not entry Is Nothing Then
Call thisdoc.ReplaceItemvalue("LastEntryBy", _
entry.Document.GetItemValue("Creator")(0))
Call thisdoc.ReplaceItemvalue("LastEntryDate", _
Format$(Cdat(entry.Document.GetItemValue("ItemDate")(0)),"mm/dd/yyyy"))
Call thisdoc.Save(True,True)
Else
Call thisdoc.ReplaceItemvalue("LastEntryBy","")
Call thisdoc.ReplaceItemvalue("LastEntryDate","")
Call thisdoc.Save(True,True)
End If
Do While Not entry Is Nothing
Set entrydoc = entry.Document
Set template = New NotesDocument(db)
Call template.ReplaceItemValue("Form","RowTemplate")
Call template.ReplaceItemValue("ItemDate", _
Format$(Cdat(entrydoc.GetItemValue("ItemDate")(0)),"mm/dd/yyyy"))
Call template.ReplaceItemValue("Creator", _
entrydoc.GetItemValue("Creator")(0))
Call template.ReplaceItemValue("Issue", _
entrydoc.GetItemValue("Issue")(0))
' *** Copy Rich text Field "Issue"
Set entrydata = entrydoc.GetFirstItem("Issue")
Set templatedata = New NotesRichTextItem(template,"Issue")
Call templatedata.AppendRTItem(entrydata)
' *** Copy Rich text Field "Action"
Set entrydata = entrydoc.GetFirstItem("Action")
Set templatedata = New NotesRichTextItem(template,"Action")
Call templatedata.AppendRTItem(entrydata)
' *** Add doclink to entry
Set doclink = New NotesRichTextItem(template,"DocLink")
Call doclink.AppendDocLink(entrydoc,"Open Entry")
Call template.ComputeWithForm(True,False)
' *** Refresh form
Call template.RenderToRTItem(datafield)
Set entry = col.GetNextEntry(entry)
Loop
Call thisdoc.ComputeWithForm(True,False)
End Sub
这就是目标文件中的样子:
答案 1 :(得分:0)
当您说表单从嵌入视图中提取数据时,该嵌入视图中是否包含一个特定文档?还是几个?
无论哪种方式,听起来你需要通过Lotusscript获取文档的句柄 - 不要忘记,嵌入式视图基本上只是一个视图。
我会尝试以类似于此的方式处理文档(如果您能够提供更多信息,我可能会更具体):
dim s as New NotesSession
dim ws as New NotesUIWorkspace
dim uidoc as NotesUIDocument
dim db as NotesDatabase
dim view as NotesView
dim doc as NotesDocument
dim SearchString as String
set uidoc = ws.CurrentDocument
set db = s.CurrentDatabase
set view = db.GetView("<embedded view name>")
SearchString = uidoc.FieldGetText("<enter name of category field on form>")
set doc = view.GetDocumentByKey(SearchString, true)
if not doc is Nothing then
' set values from doc here, ie...
thisVal = doc.value1(0)
thatVal = doc.value2(0) ' etc
' then you can form your email
Dim MailDoc as New NotesDocument(db)
MailDoc.Form = "Memo"
MailDoc.Subject = thisVal
MailDoc.Body = thatVal
MailDoc.SendTo = "name@whatever.com"
call MailDoc.Send(false)
else
msgbox "Can't find document"
end if
答案 2 :(得分:0)
据我了解,您正尝试使用文档中的存储表单功能通过电子邮件发送文档。这个想法是,接收电子邮件的人得到了一个发送者 - 看到的是我对文档的看法。那是对的吗?
我不相信它可以按照您想要的方式使用嵌入式视图,因为嵌入式视图元素仅限于引用同一数据库中的视图 - 并且电子邮件收件人正在其邮件数据库中查看文档视图不存在。有一些方法可以构建可以有效绕过相同数据库限制的Notes应用程序(请参阅here),但不能通过电子邮件发送所有应用程序代码。您只能通过电子邮件发送文档和存储的表单。