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

-
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