How to send "Show single category" embedded view in Email?

Hi,I have a form with a Show single category embedded view, the embedded view will be showing according another category field on its top. Now I have a scheduled agent which will run once a week, when this agent are running on the mid-night,it will set the category field, and the embbed view will show the embedded view in the form, the agent will send this embedded view as a notes document to clients.

Now the problem is the How to Refresh the back end document to let the embedded view save with the document? If I open the form with that embedded view myself and fill in the category field and press F9 key, the embedded view is showing up,but not for the backend agent. How to make the agent run the same way, I mean when the agent set the category field on the backend, and press F9 key(no possible on backend), the embedded view is showing up and save with the document, then send it by email. computewithform is not working.

Any other clues?

Thanks for any help,

Subject: How to send “Show single category” embedded view in Email?

Embeded views are just a UI window into a real view - they cannot be “saved” or “mailed”. They only exist in open, front-end UI-documents, but not in saved back-end documents.

I think you’ll need to build a report, one line per document, possibly with a doc-link, and mail that.

Subject: RE: How to send “Show single category” embedded view in Email?

Hi,Graham:Thanks a lot for the help,

Yes, actually I want to build a report which will display a notes document collection which contains many notes documents, and have a doc link on each row of report, because not all of data of notes document can be loaded on each row, so user can click it and open each document.

If embedded view can not be built on this case, do you know how to build this report?

Thanks again for you help,

Subject: RE: How to send “Show single category” embedded view in Email?

You’ll need to use Lotus Script for this.

Get a collection of your documents.

Either thorught a search, to get a true collections

Or by scanning each document in a view, and processing only those you need.

Use the RichText methods to build a report in a new document.

Append data from the document fields

Append a link to the document

Once the report is built, e-mail it.

I’ll include an example that one of my databases uses below.

Public Class recipient

Public Name As String

Public outstanding() As notesdocument

End Class

Sub Initialize

' Define the working items

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument



' These are the Rich-text styles we want to have on the note

Set norm = session.CreateRichTextStyle

norm.bold = False

norm.underline = False

norm.fontsize = 10

norm.notescolor = COLOR_BLACK



Set BBU = session.CreateRichTextStyle

BBU.bold = True

BBU.underline = True

BBU.fontsize = 12

BBU.notescolor = COLOR_BLACK



Set BOLD = session.CreateRichTextStyle

BOLD.bold = True



Set UNBOLD = session.CreateRichTextStyle

UNBOLD.bold = False



Set RED = session.CreateRichTextStyle

RED.NotesColor = COLOR_RED



Set BLUE = session.CreateRichTextStyle

BLUE.NotesColor = COLOR_BLUE



Set GREEN = session.CreateRichTextStyle

GREEN.NotesColor = COLOR_DARK_GREEN



' Define the list to hold the recipients

Dim sendto List As recipient



' Get the DB pointer

Set db = session.CurrentDatabase



' Get the view

Set View  = db.GetView( "Customer Status Documents" )



' Loop through the documents to be processed by this agent

Set doc = view.GetFirstDocument



While Not(Doc Is Nothing)

%REM

	 We need to deside if this document needs a reminder created.



	The criteria are ...



		Ignore EDI documents

		All new documents

		All documents pending review

		All documents under review

		and NOT archived

%END REM

	' Check for EDI documents

	service = doc.Service(0)

	' Check for NEW documents

	status = doc.Status(0)

	' Check for documents under review

	rflag = doc.RFlag(0)

	' Check for documents needing review

	review = doc.Next_Review(0)

	' Ignore archived documents

	archive = doc.Archived(0)

	

	If service <> "EDI" And (status = "New" Or rflag = "1" Or review < Today) And archive <> "Yes" Then		



		' Add the item to the reminder list

		

		' See if we need to create this recipient

		who = doc.Rep(0)

		If Not Iselement(sendto(who)) Then

			Set sendto(who) = New recipient

			Set userName = New NotesName(who)

			sendto(who).name = userName.Common

			Redim Preserve sendto(who).outstanding(0)

		End If

		

		num = Ubound(sendto(who).outstanding) +1

		Redim Preserve sendto(who).outstanding(num)

		Set sendto(who).outstanding(num) = doc

	End If

	

	Set doc = view.GetNextDocument(doc)

Wend



' Now we have all of the documents processed, build a report for each Rep



Forall person In sendto

	

	Set memo = New NotesDocument(db)

	memo.Subject = "Customer Status Review memo"

	Set pic = memo.ReplaceItemValue( "_ViewIcon", 34 )

	

	Set rtitem = New notesrichtextitem(memo, "Body")     

	Call rtitem.addnewline(1)

	Call rtitem.AppendStyle( norm )

	Call rtitem.appendtext("Good morning " + person.name + ". This is your weekly report on Customer Status documents that require your attention.")

	

	' Get the number of documents

	count = Ubound(person.outstanding)

	

	Call rtitem.addnewline(2)

	Call rtitem.appendtext("  The following are the documents that require your attention.  Please update each document, ")

	Call rtitem.addnewline(1)

	Call rtitem.appendtext("  and conduct a COS review with the customer for STANDARD and EXTENDED customers")

	Call rtitem.addnewline(2)

	Call rtitem.appendtext("  Once all information is updated, press the [Document Reviewed by Rep] button.")

	Call rtitem.addnewline(2)

	

	Dim open_for As Integer

	For i = 1 To count

		Set doc = person.outstanding(i)

		

		status = doc.Status(0)

		rflag = doc.RFlag(0)

		review = doc.Next_Review(0)

		

		If status = "New" Then

			Call rtitem.AppendStyle( BLUE )

			Call rtitem.appendtext("      This document is in NEW status and needs to be SUBMITTED.  ")

		Elseif rflag = "1" Then

			Call rtitem.AppendStyle( GREEN )

			Call rtitem.appendtext("      This document is assigned to you and needs to be reviewed.  ")

		Elseif review < Today Then

			Call rtitem.AppendStyle( RED )

			Call rtitem.appendtext("      This document has just been assigned to you and needs to be reviewed.  ")

			' Mark is as under review

			doc.RFlag = "1"

			' Update the log

			existing_log = doc.Notes(0)

			new_log = Now + " - " + session.CommonUserName + " : Status changed to Under Review by weekly agent."_

			+ Chr(10) + " " + Chr(10) + existing_log

			doc.Notes = new_log

			Call doc.save(False,False)

		Else

			Call rtitem.AppendStyle( RED )

			Call rtitem.appendtext("      *** OPPS - This document was selected but I don't know why.  ")

		End If

		

		Call rtitem.appenddoclink(doc,"Customer Status Document")

		Call rtitem.addnewline(1)

		reviewed = doc.last_reviewed(0)

		If reviewed = "" Then

			Call rtitem.appendtext("      This record has never been reviewed")

		Else

			open_for = Today - reviewed

			Call rtitem.appendtext("      It has been " +Str(open_for) +" days since this record has been reviewed")

		End If

		

		Call rtitem.addnewline(1)

		status = doc.Cust_Status(0)

		

		If status = "Base" Then

			Call rtitem.appendtext("      This is a BASE customer, so no COS review is required")

		Elseif status = "Standard" Then

			Call rtitem.appendtext("      This is a STANDARD customer, so a COS review is required")

		Else

			Call rtitem.appendtext("      This is an EXTENDED customer, so a COS review is required")

		End If

		

		Call rtitem.addnewline(1)

		Call rtitem.appendtext("      Customer Name : " + doc.Customer_Name(0))

		Call rtitem.appendtext("      Service : " + doc.Service(0))

		Call rtitem.addnewline(2)

		Call rtitem.AppendStyle( NORM )

		

	Next

	Call rtitem.AppendStyle( UNBOLD )

	

	Call rtitem.appendtext("--- End of Report ---")

	

	Call memo.Send(False, Listtag(person)+"@IBMCA" )

	

	Delete memo

	

End Forall

End Sub

Subject: RE: How to send “Show single category” embedded view in Email?

Hi,Graham:Thanks a lot for your help, your codes are really helps, I will study your codes. Actually I was thinking this way when I designing the codes, but I just thinking it is too complicated.

That is why I am think use the Single Category embedded view feature to do this. The problem is how to save a embedded view on backend document, just like I mentioned on previous post. You said the embedded view can not be saved on backend, and send by email. I tested to menually save it on the front end and as long as I got the back end document, then I can send it. I have tried it and I got the embedded view in my notes email. So that means I can send the embedded view document. Now the problem is how to save the embedded view on back end side as a single category embedded view?

Because if this embedded view way is working, it will be easy.

But if it is not working, then I will use your codes to do it.

Thank you very much again for all of your help, really appreciate.