Append doclink to another document in other database

Hi, i have the following code.I need add a doclink(uidoc) into a richtext field in another document.

Const DB_I = “DB_Inventory”

Set view=dbLocal.GetView(“Listas”)

Set docname=view.GetDocumentByKey(DB_I , True)

Set dbInv=sesion.GetDatabase(Strleft(docname.ContenidoLista(0),“:”) ,

Strright(docname.ContenidoLista(0),“:”))

Set vInv=dbInv.GetView(“ALL”)

key=doc.AppId(0)

Set dInv=vInv.GetDocumentByKey(key$)

Set rtlink = New NotesRichTextItem(dInv,“ChgReq”)

If rtlink.Type = RICHTEXT Then

Call rtlink.AppendDocLink(doc,“”,“”)

End If

dInv.Form=“Ficha”

Call dInv.Save(True,False)

any idea?

thanks in advance. sorry for my english.

Subject: Append doclink to another document in other database

Where do you define doc?

Subject: RE: Append doclink to another document in other database

Doc is uidoc.documentthanks

Subject: Append doclink to another document in other database

You might want to try:( I assume you have a valid handle to doc )

Set dInv=vInv.GetDocumentByKey(key$)

set rtlink = dInv.GetFirstItem(“ChgReq”)

if rtlink is nothing then

Set rtlink = New NotesRichTextItem(dInv,"ChgReq")

end if

If rtlink.Type = RICHTEXT Then

Call rtlink.AppendDocLink(doc,“”,“”)

else

tmpval = rtlink.Text

rtlink.Remove

Set rtlink = New NotesRichTextItem(dInv,“ChgReq”)

rtlink.AppendText(tmpval)

Call rtlink.AppendDocLink(doc,“”,“”)

end if

This code will help get around the problem of a pre-existing ChgReq field on the target document. There could be more than one ChgReq item on the dInv and then you might want to use

else

tmpval = rtlink.Text

set rtlink = dInv.ReplaceItemValue(“ChgReq”, “”) ’ this will get rid of all occurences of ChgReq on dInv

rtlink.Remove

Set rtlink = New NotesRichTextItem(dInv,“ChgReq”)

rtlink.AppendText(tmpval)

Call rtlink.AppendDocLink(doc,“”,“”)

end if

I don’t know if duplicate items on dInv is the issue but if it is, this code should help.

Subject: RE: Append doclink to another document in other database

Thanks Phil, but i change the code and the problem persist.field “ChgReq” in dInv (document database b) is empty.

I have a field Authors, value “”.

I don’t know what is happening. No errors, but doclink is not append dInv.

Thanks.

Subject: RE: Append doclink to another document in other database

Add rtlink.AppendText("Click here: ") to your code as well just to make sure that something else isn’t going wrong instead of the doclink part:

If rtlink.Type = RICHTEXT Then

Call rtlink.AppendText("Click here: ")

Call rtlink.AppendDocLink(doc,“”,“”)

End If

Do any other modifications to dInv show up from your code?

If “Click Here” doesn’t show up, something else is broken.

Have you stepped through with the LotusScript debugger on to make sure that all of the code that you expect to execute is executing?

Subject: RE: Append doclink to another document in other database

Phil, now i have an errorset rtlink = dInv.GetFirstItem(“ChgReq”)

Type Mismatch