Printing document with embedded view - Show single category

Printing document with embedded view - Show single category

We have training database that have embedded view - show single category.

Each course for staff training contains lot of information with names of participants (embedded view). Our embedded view has column set to 'display values as icons' which represents status of participants within course.

Problem was printing these documents. When we print courses we lose list of participants. Embedded view is printed as grayed out box saying "view: name of embedded view".

To mimic what you see on screen when printing documents I created another form with 4 rich text fields into which I imported 4 images that represent status of participants within course.

I also created another form "Print" which I am using to generate report.

View like report is generated in "Report" rich text field on "Print" Form.

Process goes like this:
Pick up the ID of currently opened document
Collect the documents with same ID (List of Participants)
Check the Status of documents
Depending of status find the rich text that holds corresponding image and append image
Write legend
Open report document and print
Close report document.

Here is action code (probably not best but works)


Sub Click(Source As Button)
	Dim session As New NotesSession
	Dim workspace As New NotesUIWorkspace
	Dim db As NotesDatabase
	Dim uidoc As NotesUIDocument
	Dim uiresults As NotesUIDocument

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

'Report UI document Dim CourseID As String Dim Collection As NotesDocumentCollection Dim View As NotesView Dim resultDoc As NotesDocument Dim doc As NotesDocument Dim n As Integer Set db = session.CurrentDatabase Set uidoc = workspace.CurrentDocument 'Get ID of current document CourseID = uidoc.FieldGetText("ID") Set View = db.GetView("Participants") Set Collection = View.GetAllDocumentsByKey(CourseID, True) 'Create the Report document using print form Set resultsDoc = db.CreateDocument resultsDoc.Form = "Print" 'Create the Rich Text Item. This is where the report goes. Also create a ' Rich Text Style object so that we can format the report Dim richText As New NotesRichTextItem(resultsDoc, "Results") Set richStyle = session.CreateRichTextStyle 'Basic report body text format richStyle.NotesFont = FONT_HELV richStyle.FontSize = 8 richStyle.Bold = False Call richText.AppendStyle(richStyle) 'Title and Cost resultsDoc.Title = uidoc.FieldGetText("CourseName") resultsDoc.TotalCost = uidoc.FieldGetText("TotalCost") 'Start generating the report For n = 1 To Collection.Count Set doc = Collection.GetNthDocument(n) Call richText.AddNewLine(1) Call richText.AppendText(Cstr(n) + ".") Call richText.AddTab(1) 'Insert Immage Dim imageView As NotesView Dim imageDoc As NotesDocument Set imageView = db.GetView("Images") Set imageDoc = imageView.GetDocumentByKey( "Images" ) Dim rtitem As Variant Dim s As String s= (doc.GetFirstItem("Status").Text) Select Case s Case "Allocated": Set rtitem = ImageDoc.GetFirstItem( "Allocated" ) Call richText.AppendRTItem(rtitem) Case "Nominated": Set rtitem = ImageDoc.GetFirstItem( "Nominated" ) Call richText.AppendRTItem(rtitem) Case "Attended": Set rtitem = ImageDoc.GetFirstItem( "Attended" ) Call richText.AppendRTItem(rtitem) Case "Not Attended": Set rtitem = ImageDoc.GetFirstItem( "NotAttended" ) Call richText.AppendRTItem(rtitem) End Select 'End Insert Immage 'Add Link Call richText.AddTab(1) Call richText.AppendDocLink(doc, "Click on link to launch the document") Call richText.AddTab(1) 'End Add Link 'Name richStyle.Bold = True Call richText.AppendStyle(richStyle) Call richText.AppendText(doc.GetFirstItem("Name").Text) 'End Name 'Job Title richStyle.Bold = False Call richText.AppendStyle(richStyle) Call richText.AddTab(1) Call richText.AppendText(doc.GetFirstItem("JobTitle").Text) 'End Job Title Next 'Add Legend Call richText.AddNewLine(3) richStyle.Bold = True richStyle.NotesColor = COLOR_BLUE Call richText.AppendStyle(richStyle) Call richText.AppendText("Legend:") Call richText.AddNewLine(1) richStyle.Bold = False richStyle.NotesColor = COLOR_BLACK Call richText.AppendStyle(richStyle) Call richText.AppendText("Nominated") Call richText.AddTab(1) Set rtitem = ImageDoc.GetFirstItem( "Nominated" ) Call richText.AppendRTItem(rtitem) Call richText.AddNewLine(1) richStyle.NotesColor = COLOR_DARK_YELLOW Call richText.AppendStyle(richStyle) Call richText.AppendText("Allocated") Call richText.AddTab(1) Set rtitem = ImageDoc.GetFirstItem( "Allocated" ) Call richText.AppendRTItem(rtitem) Call richText.AddNewLine(1) richStyle.NotesColor = COLOR_DARK_GREEN Call richText.AppendStyle(richStyle) Call richText.AppendText("Attended") Call richText.AddTab(1) Set rtitem = ImageDoc.GetFirstItem( "Attended" ) Call richText.AppendRTItem(rtitem) Call richText.AddNewLine(1) richStyle.NotesColor = COLOR_RED Call richText.AppendStyle(richStyle) Call richText.AppendText("Not Attended") Call richText.AddTab(1) Set rtitem = ImageDoc.GetFirstItem( "NotAttended" ) Call richText.AppendRTItem(rtitem) Call richText.AddNewLine(1) 'End of legend 'Save results document Call resultsDoc.Save(True, False) 'Display results document Set uiResults = workspace.EditDocument( False, resultsDoc, True) Dim printUidoc As NotesUIDocument Set printUidoc = workspace.CurrentDocument Call printUidoc.Print( 1 ) Call printUidoc.Close End Sub

This was first published in February 2002

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.