I have built a form that relates to a product. The product consists of between 2 & 4 PDF files, depending on the answers to various questions on the form. As the form is filled in, certain sections & questions dynamically appear and disappear, as not all questions apply to all products. This is achieved with various hide-when formulae.
The problem is with the Rich Text Lite fields I am using to store the PDF files. As you may or may not know, there is an issue with hiding Rich Text fields using Hide When formulae. It's something to do with the paragraph(s) contained in the Rich Text field actually taking on the Hide When formulae for itself, rather than just the field displaying or not. Anyway, the recommended workaround involves placing the Rich Text field on a computed subform, rather than directly in the main Form. But the trouble is, this only hides or displays the field when the Document is opened. So answering the questions so that one should appear or disappear doesn't take effect unless you close & re-open the Document.
I have thought of a solution to this, but seem to be having great difficulty in getting it to work. The solution involves placing the Rich Text fields on Computed Subforms, but displaying these on a separate Form displayed in a DialogBox. Cool, huh? Initially I thought I'd have to have an Action Button & associated DialogBox Form for each of the four Rich Text fields, but as this Document is created when you press the Action Button, the Computed Subform trick works a treat, hiding & displaying each field correctly at the time the DialogBox is displayed.
Now here's the problem. NotesUIWorkspace.DialogBox
() can be called using the existing Document, or using an alternative NotesDocument. If I use the existing Document, then any existing PDF files are brought from the underlying Document & displayed in the correct field in the DialogBox. But, when I press OK, instead of being saved back to the field from whence it came, it gets attached to the bottom of the Document, below all the fields. And from there I can't seem to find it in LotusScript, & even if I could, I'd have no way of knowing which file was which. If, on the other hand, I create a new NotesDocument in the LotusScript, then display that using the DialogBox, then I can't seem to get any existing PDF files from underlying Document & display them in the DialogBox in the first place. And I dare say I will have the same problem trying to get it back out & into the underlying Document again. The reason is that I can only seem to attach a file from an actual file in the filesystem, & extracting it then attaching it again seems very inefficient.
I've now just tried to get it to work using NotesItem.CopyItemToDocume
nt, to copy the files between the two Documents, but I can get it to go into the DialogBox, but not back again.
Does anyone have any idea how I can solve this?
Here's my current code from the Action Button:
Option Declare
Sub Click(Source As Button)
Dim session As New NotesSession, dbThis As NotesDatabase
Dim ws As New NotesUIWorkspace, uiDoc As NotesUIDocument
Dim strComponents(3) As String, docProduct As NotesDocument, docDialog As NotesDocument, rtiProduct As NotesRichTextItem, rtiDialog As NotesRichTextItem
Set dbThis = session.CurrentDatabase
Set uiDoc = ws.CurrentDocument
strComponents(0) = "PDF1"
strComponents(1) = "PDF2"
strComponents(2) = "PDF3"
strComponents(3) = "PDF4"
Set docDialog = dbThis.CreateDocument()
Call uiDoc.Save()
Set docProduct = uiDoc.Document
Forall c In strComponents()
Call docDialog.ReplaceitemValue
(c & "Status", docProduct.GetItemValue(c & "Status")(0))
Set rtiProduct = docProduct.GetFirstItem(c & "File")
If Not Isempty(rtiProduct.Embedde
dObjects) Then
Set rtiDialog = rtiProduct.CopyItemToDocum
ent(docDia
log, c & "File")
End If
End Forall
If ws.DialogBox("dialogSubmit
Files", True, True, False, False, False, False, "Submit/Edit/Resubmit Source File(s)", docDialog, True, False, False) Then
Forall c In strComponents()
Set rtiDialog = docDialog.GetFirstItem(c & "File")
If Not(rtiDialog Is Nothing) Then
If Not Isempty(rtiDialog.Embedded
Objects) Then
Set rtiProduct = docProduct.GetFirstItem(c & "File")
Call rtiProduct.Remove()
Set rtiProduct = rtiDialog.CopyItemToDocume
nt(docProd
uct, c & "File")
Call docProduct.Save(True, False)
End If
End If
End Forall
Call uiDoc.Reload
End If
End Sub
Start Free Trial