Selected Documents in an Embedded View

I have a workspace dialog that has an embedded view on it. It contains a list of employee names and users of this dialog box will check off names of people to assign a request to. I would like to be able to then grab those names selected and assign the appropriate documents to them. We currently use a list box field, but sometimes we receive the 65 K issue because of the data coming through.

I know I could use the picklist function but our customer would like to limit the number of clicks a user has to make. The embedded view would work great but I need to be able to identify the names selected from it.

Thanks in advance

Subject: Wondering?

Could you write an agent (action button on the form) to get a handle on each name in the embedded view with script? Not sure about the “assign appropriate documents” or what exactly that means. However, if you get a handle to each name then perhaps…

Subject: RE: Wondering?

That would be the question. can I have an a script that could get a handle on the documents selected in an embedded view from a button on the form containing the embedded view? An example of simple script would be appreciated.

Thanks in advance

Subject: RE: Wondering?

To get a handle to the selected documents in an embedded view:

  1. on the embedded view properties, check off “Show Action Bar” (new in R6)

  2. create a view action on that embedded view to house your LS processing code

  3. in your LS, use the NotesDatabase.UnprocessedDocuments property to cycle through the selected documents

Hope that helps

Subject: Try this…

place behind an action button on the form:

Dim w As New notesuiworkspace

Dim uidoc As notesuidocument

Dim value As String

Set uidoc = w.currentdocument

value = uidoc.fieldgettext(“the name of the field containing the name you want”)'the field that has the value you want…

Subject: Hmmm…won’t work!

Subject: Here’s a better example.

In the embedded view example, their is a $$ amount column and the following code adds up the $$ value for each item listed in the embedded view and displays a messagebox with the total. Hope this helps.

'*****add embedded $$ amounts from view

'**** if field contains incorrect value, ie. $ sign, exit

On Error Goto errorhandler



Dim session As New NotesSession

Dim workspace As New notesuiworkspace

Dim db As NotesDatabase

Dim view As NotesView

Dim column As NotesViewColumn

Dim item As notesitem

Dim doc, doc2 As NotesDocument

Dim uidoc As notesuidocument

Dim count As Integer

Dim x, y, z, t As Integer

Dim keyvalue As String



Set db = session.CurrentDatabase

Set uidoc = workspace.currentdocument

Set doc=uidoc.document



'***** place document in edit mode

If Not uidoc.EditMode Then

	uidoc.EditMode = True

End If



'***** get the unique project id

keyvalue = uidoc.FieldGetText( "projid" )

Set view = db.GetView("EmbedTask")



'***** initializes the views

Forall c In view.Columns

	If ( c.IsSorted And c.IsCategory ) Then

		Set column = c

		Exit Forall

	End If

End Forall



'***** get the document by project id

Set doc2 = view.GetDocumentByKey(keyvalue, True)	

count = 0



Do While Not ( doc2 Is Nothing )

	If ( doc2.ColumnValues( column.Position - 1 ) =  keyvalue ) Then

		

		'***** get the budget $$ value

		Set item = doc2.GetFirstItem("taskbudg")

		x= item.Values(0)

		count = count + 1

		

		'**** the next two if statements ensure correct value is used 

		If count = "1" Then

			y = "0"

		End If

		

		If x <> "0" Then

			

			If count > "1" Then        

				y = x

			End If

			

			'**** next if needs for unapproved tasks

			If x = "" And y = "" Then

				Messagebox "A task needs approval before it can be included in total."_ 

				& " " + Chr$(13) & Chr$(10) _

				& " " + Chr$(13) & Chr$(10) _

				& "The total only contains approved tasks.", 32, "Notice"					

				Exit Do

			End If	

			

			If y = "0" Then

				z = Cdbl(y) + x 

			

			Else

				z =  z + x

			End If

			

		End If

		

	Else

		Exit Do

	End If

	

	Set doc2 = view.GetNextDocument(doc2)

	

	'*****reset x to 0

	x = "0"

	

Loop



'**** if no task found, exit

If doc2 Is Nothing And count = "0" Then

	Messagebox "No tasks found.", 32, "Notice"

	Exit Sub

End If



'**** display total value

Messagebox z





Exit Sub

errorhandler:

Msgbox "Budget amount may contain an incorrect character."_

& " " + Chr$(13) & Chr$(10) _

& " " + Chr$(13) & Chr$(10) _

& "Contact Help Desk for assistance.", 32, "Notice"		

Exit Sub

Subject: Place the example code behind an action button on the form containing the embedded view.

Subject: RE: Here’s a better example.

This example looks like it sums the values in all the documents which would be shown in the embedded view. What if he wanted to sum only the values of selected documents in the embedded view using a Form Action (not a View Action)?