When I use “view embebbed” in form is not possible print or see all view lines, just 10 lines. How I can do this? Please I hope know the solution, because my project is stoped.Thanks
Subject: One solution for printing a form with an embedded view
Unfortunately that’s a known limitation when printing a form with an embedded view. I use the following process to work around the issue. It’s a little work and you have to maintain a separate print version of the main form but the end results is quite satisfactory.
(1) Create a copy of your primary form but remove the embedded view and replace it with a rich text field (call the field “ViewOutput”). I have found it best to set the font to Arial 1 (this will be overridden by the formatting of the contents of the form in step (2)). You may also want to change all the editable fields on the form to computed for display and remove any action buttons. Also, on this form add two new action buttons as follows:
Button Label: Print
Formula: @Command([FilePrint])
Button Label: Close
Formula: FIELD SaveOptions:="0"; @Command([FileCloseWindow])
(2) Create another new form with a table on it with cells that match the columns from the embedded view. Place the fields from the forms in the relevant cells.
(3) In the primary form that contains the embedded view create a button labeled “Print Version” and have it coded to do the following:
(i) Create a new document based on the form created in (1)
(ii) Place a new rich text item on it called "ViewOutput"
(iii) Go through all of the documents in the embedded view and, for each one do the following:
(a) Change the form name to the name of the form in (2)
(b) Use the notesdocument.rendertortitem method to put a picture of the document in the rich text item
(c) Open the temporary print version of the document in the UI.
Example of the code for the “Print Version” button in (3):
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim vc As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim view As NotesView
Dim docToProcess As NotesDocument
Dim success As Integer
Dim answer As Integer
Dim key As String
Dim iCount As Integer
Dim i As Integer
Set db = session.currentdatabase
Set uidoc = ws.currentdocument
Set doc = uidoc.document
key$ = Cstr(doc.GetItemValue("DocID")(0))
'save the current open document if necessary
If uidoc.EditMode Then
Call uidoc.Save
End If
doc.SaveOptions = "0" 'necessary to keep the user from being prompted to save the document when we close it
Call uidoc.Close(True)
Call doc.ReplaceItemValue("Form", "FormPrintable") 'temporarily switch the form to the printable version that contains a rich text field instead of the embedded view
Call doc.ReplaceItemValue("SaveOptions", "0") 'keep the temporary version of the form from being saved
Set rtitem = New NotesRichTextItem( doc, "ViewOutput" ) 'add the field that will contain the table rendered documents
'Process each detail document from the embedded view
Set view = db.GetView("EmbeddedViewName")
Set vc = view.GetAllEntriesByKey(key$)
If vc.Count > 0 Then
Set entry = vc.GetFirstEntry()
While Not(entry Is Nothing)
Set docToProcess = entry.document
Call docToProcess.ReplaceItemValue("Form", nameOfFormWithTable)
success = docToProcess.RenderToRTItem( rtitem ) 'appends the table formatted contents of the target document to the rich text item in the primary document
Set docToProcess = Nothing
Set entry = vc.GetNextEntry(entry)
Wend
End If
'call ComputeWithForm and open the doc in the UI
Call doc.ComputeWithForm(False, False)
Call ws.EditDocument(False, doc)
Subject: Worked great!
I don’t understand why some users can print fine and others can’t, but this is a good solution for those that cannot. Thanks for posting!
Subject: Glad that worked for you.