Using AppendDocLink or HotSpotText from PickListCollection. PLEASE Help me!

Hi!

I have a button in my current document (in edit mode) and when i click on this button:

  • first, appear a dialog box with document collection, and i can select some documents;

  • make some calculation;

  • and for every document add a document link in my field Product_NO_INList (rich text field).

My problem is:

  • to add a document link doesn’t work :frowning:

  • my rich text field for links it’s empty

Please help me with a suggestion, or if you have another code example for appenddoclink or hotspottext, to insert this links in my current doc.

Thanks!

##########################################

Sub Click(Source As Button)

On Error Goto ErrorHandler	



Dim session As New NotesSession	

Dim ws As New NotesUIWorkspace

’ Dim for current document

Dim db As NotesDatabase

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

’ Dim for lookup document

Dim lookupdb As NotesDatabase

Dim lookupcollection As NotesDocumentCollection

Dim lookupdocprof As NotesDocument	

Dim lookupdoc As NotesDocument

Dim product_code As String	



Dim qty_reservation As Integer

Dim qty_sold As Integer

Dim res_sold As Integer

Dim qty_work As Integer



Dim product_in_collection As Variant



Dim rtitem As NotesRichTextItem



Dim confirmation As Variant



Set db = session.CurrentDatabase



Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document

Set rtitem = New NotesRichTextItem( doc, "Product_NO_INList")



Set lookupdb = session.CurrentDatabase

Set lookupdocprof = db.GetProfileDocument("Application Profile")	



Set lookupcollection = ws.PickListCollection(1, True, lookupdocprof.DbServer0(0), lookupdocprof.DbPath0(0), "LookupINByCode",  "Associate with Product IN", "Please select document(s) who you want to associate with this Reservation.", doc.Product_Code(0))





confirmation = ws.Prompt( PROMPT_YESNO, "Confirmation", "Do you realy want to create this document for reception?")	



If confirmation Then	

	

	If lookupcollection.Count <> 0 Then

		

		

		

		Set lookupdoc = lookupcollection.GetFirstDocument

		

		

		qty_work = doc.Product_Reservations(0) - doc.Product_OUTReservations(0)

		Print "(DEFAULT) qty_work: " & qty_work

		

		Redim qty (1 To lookupcollection.Count, 1 To 2)

		Redim product_in_collection (1 To lookupcollection.Count+1)

		

		

		For x = 1 To lookupcollection.Count

			qty(x,1) = lookupdoc.Product_INStock(0) - lookupdoc.Product_OUTStock(0)

			qty(x,2) = lookupdoc.Product_NO_IN(0)

			

			qty_reservation = doc.Product_Reservations(0) - doc.Product_OUTReservations(0)

			

			If qty_work > 0 Then

				

				If qty(x,1) < qty_reservation Then

					qty_sold = qty(x,1)

					res_sold = qty(x,1)

					qty_work = qty_work - qty(x,1)

					

					doc.Product_OUTReservations = doc.Product_OUTReservations(0) + res_sold

					lookupdoc.Product_OUTStock = lookupdoc.Product_OUTStock(0) + qty_sold

					doc.Reservation_Status = "Order"

					lookupdoc.Product_Status = "Sold"

					

					

					Call rtitem.AppendDocLink( lookupdoc, "link" )

					Call rtitem.Update()

					

					Call lookupdoc.Save(True,True)

					

					Print "(LINE 1) qty_work: " & qty_work & " qty_sold: " & qty_sold & " res_sold " & res_sold

					

				Elseif qty(x,1) = qty_reservation Then

					qty_sold = qty_reservation

					res_sold = qty_reservation

					qty_work = qty_work - qty(x,1)

					

					doc.Product_OUTReservations = doc.Product_OUTReservations(0) + res_sold

					lookupdoc.Product_OUTStock = lookupdoc.Product_OUTStock(0) + qty_sold

					doc.Reservation_Status = "Stock"

					lookupdoc.Product_Status = "Sold"

					

				

					Call rtitem.AppendDocLink( lookupdoc, "link" )

					Call rtitem.Update()						

					

					Call lookupdoc.Save(True,True)

					

					Print "(LINE 2) qty_work: " & qty_work & " qty_sold: " & qty_sold & " res_sold " & res_sold					

					

				Elseif qty(x,1) > qty_reservation Then

					qty_sold = qty_reservation

					res_sold = qty_reservation

					qty_work = qty_work - qty_reservation

					

					doc.Product_OUTReservations = doc.Product_OUTReservations(0) + res_sold

					lookupdoc.Product_OUTStock = lookupdoc.Product_OUTStock(0) + qty_sold

					doc.Reservation_Status = "Stock"

					lookupdoc.Product_Status = "Stock"

					

				

					

					Call rtitem.AppendDocLink( lookupdoc, "link" )

					Call rtitem.Update()						

					Call lookupdoc.Save(True,True)

					

					Print "(LINE 3) qty_work: " & qty_work & " qty_sold: " & qty_sold & " res_sold " & res_sold					

					

				Else

					Print "Out of process!"

				End If

			Else

				Print "QTY WORK: Out of process!"

			End If

			

			Set lookupdoc = lookupcollection.GetNextDocument(lookupdoc)

			

		Next

	End If

	

	

	

	

Else

	Exit Sub

End If

TheEnd:

Exit Sub

ErrorHandler:

Print "At line " & Str$(Erl) & ": " & Error$

Resume TheEnd

End Sub

Subject: RE: using AppendDocLink or HotSpotText from PickListCollection. PLEASE Help me!

As has been discussed many times in these forums, back-end changes to the rich text field in a document you’re editing, are not reflected on screen. You must close and reopen the document to see the changes. You can do this with uidoc.Close and ws.EditDocument. Search in here for more detail.

Subject: using AppendDocLink or HotSpotText from PickListCollection. PLEASE Help me!

You won’t see changes to rich text fields until the ui document has been closed and re-opened – this may be why you don’t think the links are there.

AppendDocLink is done to the NotesDocument object rather than the NotesUIDocument: make sure a ui doc save doesn’t overwrite the change you’ve made to the back-end.

Also, make sure you have a default view assigned in the database: AppendDocLink requires this (something that Domino Designer help consistently neglects to mention).

HTH

Subject: RE: using AppendDocLink or HotSpotText from PickListCollection. PLEASE Help me!

As Ben wrote, AppendDocLink is done to the NotesDocument and saving the NotesUIDocument can overwrite your changes. To get around this so the doc link can be shown in the UI without having to save the doc first, this seemed to work:

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/01d300d3f4919ce385256e760060feae?OpenDocument

On a side note, I found that this method also works for Computed Subforms. In the documentation, it states “Subform formulas cannot be refreshed while the document is open.” but working with the backend doc gets around this.

Bryce

Subject: RE: using AppendDocLink or HotSpotText from PickListCollection. PLEASE Help me!

grate code!works, but for one selected document from picklistcollection…

Can i use this if i want to select more documents from picklistcollection and insert this doclinks in my richtext filed?

now, i have a button for my richtext field where i insert ID’s (a number) from selected documents (from picklistcollection), but i want to make hotspottext (or doclinks)this ID’s, in my richtext filed (current document)…

so, you used this code for more selected documents?

thanks!

(sorry for my english) :slight_smile: