Hi. I have a problem in attaching doclinks to a rich text field through lotus script. I have used “Call rtitem.AppendDocLink” to do that. The problem is instead of doclikns the database link of that document is getting attached. Can anyone please help me out.
Subject: Problem with attaching doclinks in richtext field
This is probably a stupid question but…
Have you tried stepping through your code in Debug mode to ensure that you do have a handle to the document that you want to link to?
Subject: RE: Problem with attaching doclinks in richtext field
Ya i have even tried that. I am getting handle to the document i want but still the db containing the doc is getting linked instead of that doc.
Subject: RE: Problem with attaching doclinks in richtext field
As per your code,
If Def_Status=“UAT” Then
'Msgbox"UAT"
Set rtitem = MyDoc.GetFirstItem(“Link_2_Mail”)
Else
'Msgbox"PS"
Set rtitem = MyDoc.GetFirstItem(“Link_2_Mail_PS”)
Then you are appending doclink of ‘thisDoc’ to this rtitem. This rtitem belongs to MyDoc. You seem to be not saving this document(Mydoc) in your code instead you are saving ‘thisDoc’. My guess is that you might not be looking at right document. Please save ‘MyDoc’ and check again whether it is saving the doclink of ‘thisDoc’ in it or not.
Subject: RE: Problem with attaching doclinks in richtext field
NO, its an editable field…
Subject: RE: Problem with attaching doclinks in richtext field
As per your observation i have saved “MyDoc” n tried. but its of no use.
Subject: RE: Problem with attaching doclinks in richtext field
If you save Mydoc, then it should save the doclink. Looks like your version of Notes might be with a bug. Please go thru the link posted by Ian F Scott above.
Subject: RE: Problem with attaching doclinks in richtext field
Thanks everyone for your response…![]()
Subject: RE: Problem with attaching doclinks in richtext field
FYI, I got exactly the same problem today when I am working in my application but with a computed RT field. Then I recollected and started a search for this posting. Finally I could able to resolve this because of Ben Langhinrich’s question in this current thread. I searched on Computed RT and finally got into a thread where a person by name Rod Whitley(one of the LN gurus) gave a clue to one of the Rich Text field victim. I applied the same thing. For now, it looks ok without getting the doclink converted to dblink. Mine is a computed RT field. Not getting any more problems. The clue is:
Add a line like this to the form’s PostOpen event:
Source.Document.GetFirstItem(“MyComputedRTField”).SaveToDisk = False
Subject: RE: Problem with attaching doclinks in richtext field
Sorry for my above posting. I tested my application in three ways. This Computed RT field is in a subform which gets displayed when the user is having rights of 3 roles(StudyRoles not the Notes Roles). Each Role has to work from within their Tabs in the document. Respective subform displays This can be created in two ways.
StudyRole1 approves the document from his tab and notifies StudyRole3. Now if StudyRole 1and StudyRole3 happened to be the same person and get the two tabs and checks for the doclink under StudyRole3 Tab, then the link seems to be fine.
If both Roles are different persons, then this doclink is getting converted to dblink even though my clue in above posting seems to be ok to some extent.
Subject: Problem with attaching doclinks in richtext field
If you use the syntax of
Call rtitem.AppendDocLink(yourdoc, “document”)
Doc link will be appended.
If the syntax you used is Call rtitem.AppendDocLink(db, “whatever”) then db link will be appended.
Which one did you use? Please check your code again.
Subject: RE: Problem with attaching doclinks in richtext field
I have used Call rtitem.AppendDocLink(yourdoc, “document”)but still i am facing that problem. When i attach the first doc link its working fine but when i add more links dblink is getting attached instead of that doclink.
Subject: RE: Problem with attaching doclinks in richtext field
Can you post the code for more clarity?
Subject: RE: Problem with attaching doclinks in richtext field
Sub Click(Source As Button) On Error Goto ErrorHandler
Dim session As New NotesSession
Dim wks As New NotesUiWorkspace
Dim dbThis As NotesDatabase
Dim uidoc As NotesUIDocument
Dim MyColl As NotesDocumentCollection
Dim MyCollForRef As NotesDocumentCollection
Dim docCollection As NotesDocumentCollection
Dim MySearchString As String
Dim MyDoc As NotesDocument
Dim MyDocForRef As NotesDocument
Dim MyNextDoc As NotesDocument
Dim field_size As Variant
Dim size_of_field As Integer
Dim counter As Integer
Dim num4 As String
Dim num5 As String
Dim num6 As Integer
Dim num7 As String
Dim num8 As Integer
Dim dnum8 As Integer
Dim num9 As String
Dim num11 As String
Dim num12 As String
Dim Document_Status As String
Dim rtitem As Variant 'NotesRichTextItem
Dim Def_Status As Variant
Dim dbUi As NotesUiDatabase
Dim strMsg As String
Dim Reference_number As String
Set dbThis =session.CurrentDatabase
'Set dbUi = wks.CurrentDatabase
'Set dbThis = dbUi.Database
Set uidoc =wks.CurrentDocument
Set docThis = uidoc.Document
Set View = dbThis.Getview("(AllProjectsforsearch)")
Set View1 = dbThis.Getview("(Lookup Defect Logs)")
uidoc.EditMode = True
Def_Status=docThis.Defect_Phase1(0)
StrMsg=""
strMsg=""
If docThis.ProjectType(0) ="" Then
StrMsg = StrMsg + Chr(13) + " Project Type"
End If
If docThis.ProjectName(0) ="" Then
StrMsg = StrMsg + Chr(13) + " Project Name"
End If
If docThis.Defect_Phase1(0) ="" Then
StrMsg = StrMsg + Chr(13) + " Defect Phase"
End If
'If docThis.Refno(0) ="" Then
' StrMsg = StrMsg + Chr(13) + " Reference Number"
'End If
If Trim(strMsg) = "" Then
Else
Print ""
Messagebox "Some mandatory fields are empty and hence the details can't be added" & Chr(13) & Chr(13) & strMsg & Chr(13) & Chr(13) & "Please fill in the required details and try again",,dbThis.Title
Exit Sub
End If
Redim Preserve Keys(0) As String
Keys(0) = docThis.ProjectName(0)
Set MyColl = View.GetAllDocumentsByKey(Keys,True)
Set MyDoc=MyColl.GetFirstDocument
'Set uidoc=wks.
If Not MyDoc Is Nothing Then
If Def_Status="UAT" Then
'Msgbox"UAT"
Set rtitem = MyDoc.GetFirstItem("Link_2_Mail")
Else
'Msgbox"PS"
Set rtitem = MyDoc.GetFirstItem("Link_2_Mail_PS")
End If
End If
Reference_number=MyDoc.Refno(0)
Document_Status=MyDoc.Status(0)
'Msgbox"Document_Status" &Document_Status
Redim Preserve Keys(0) As String
Keys(0) = Reference_number
Set docCollection = View1.GetAllDocumentsByKey(Keys,True)
If docThis.Defect_Phase1(0)<> Document_Status Then
Messagebox "The Project document is not in the above clicked Defect Phase" ,(0+16), "Wrong Selection"
Exit Sub
End If
Set doc = dbThis.CreateDocument
doc.Form="DefectDetails"
'Update the header information in the details form
doc.DefNumber=docCollection.Count+1
'Msgbox"doc.DefNumber:"&doc.DefNumber(0)
doc.Refno = Reference_number
doc.ProjectName = docThis.ProjectName
doc.ProjectType = docThis.ProjectType
doc.Developer = ""
doc.Status = docThis.Defect_Phase1
doc.Description = "For details click "&docThis.Refno4mail(0)
doc.DefectType = "--"
doc.DefectSeverity ="--"
doc.DefectPhase = docThis.Status
doc.PreReview = "Yes"
doc.DevReworkEffort = "0.0"
doc.ActionTaken="--"
doc.Createdon=Now
doc.Createdby=session.CommonUserName
doc.DefectCause ="--"
doc.Customers=docThis.DisplaySent
doc.MCallStatus="Open"
doc.Defect_Current_Status="Open"
doc.Back_To_Developer="NA"
Call rtitem.AppendDocLink( docThis, "Click here" )
'Call rtitem.AppendText( ""&Chr(10) &Chr(10) )
Call rtitem.AppendText( " Link to the Mailed In Defect with Reference Number:"&docThis.Refno4mail(0) &Chr(10) &Chr(10) )
If docThis.Defect_Phase1(0) ="UAT" Then
num4=docCollection.Count+1
MyDoc.TotalDefects=Cstr(num4)
num5=MyDoc.USDefects(0)
num7=MyDoc.EQADefects(0)
num6=Cint(num5)+Cint(num7)
num8=Cint(num4)-Cint(num6)
MyDoc.UATDefects=Cstr(num8)
MyDoc.TotPreDefects=Cstr(num4)
Else
If docThis.Defect_Phase1(0) ="PS" Then
num4=Cstr(docCollection.Count+1)
MyDoc.TotalDefects=Cstr(num4)
num5=MyDoc.USDefects(0)
num7=MyDoc.EQADefects(0)
num9=MyDoc.UATDefects(0)
num11=MyDoc.GNATsTDefects(0)
num12=MyDoc.PICDefects(0)
'Msgbox"Cint(num9)"&num9
num6=Cint(num9)+Cint(num5)+Cint(num7)+Cint(num11)+Cint(num12)
dnum8=Cint(num4)-Cint(num6)
MyDoc.PSDefects=Cstr(dnum8)
'Call uidoc.FieldSetText("ActionTaken1","--")
num6=Cint(num11)+Cint(num12)+dnum8
MyDoc.TotPostDefects=Cstr(num6)
End If
End If
docThis.CallStatus="Logged"
docThis.MCallStatus="Open"
docThis.Logged="Logged"
Call uidoc.Refresh
Call docThis.Save(False,True)
Call doc.Save(False,True)
Call doc.ComputeWithForm( False, False )
Call MyDoc.Save(False,True)
Call uidoc.Save
Messagebox"Defects have been logged successfully",(0),"Logged"
'Call uidoc.close
'Msgbox Cstr(MyDoc.lastmodified)
ErrorHandlerResume:
' Clear the status bar
Print ""
Exit Sub
ErrorHandler:
'See what error occurred
'Report error to the user
Msgbox "The following error was encountered..." & Chr(10) _
& Chr(10) _
& "Line " & Str(Erl) & ", Error " & Str(Err) & " - " & Error, 48, "Error"
' Now resume
Resume ErrorHandlerResume
Final:
' Clear the status bar
Print ""
End Subb
End Sub
Subject: Problem with attaching doclinks in richtext field
Is it a computed rich text field?
Subject: What Point Release Of Notes 6.5 Are You Using
May be a known issue that was fixed in 6.5.5