Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

AppendDocLink in UI document

Posted on 2002-05-17
17
Medium Priority
?
1,650 Views
Last Modified: 2013-12-18
Ok guys maybe you can help... I want to be able to insert a link to a backend database in the UI document that I am in.  In my code I have a handle to the UI document (called CurrentDoc) and the backend database (called SourceDb) but it doesn't seem to work in a frontend document.  I want the user to press a button and instantly a doclink gets created and pasted into a rich text field on the document he is looking at.
0
Comment
Question by:snocross
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 4
  • +1
17 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7016322
NotesRichTextItem.AppendDocLink is the method to append a link to db or view or doc.

In your case, the uidoc richtext field updates will not be realized until you save the document and close and reopen it.

So after creating the db link, use these methods in a sequence

' After doclink is generated in the rt field
set uidoc = ws.CurrentDocument
set note = uidoc.Document
uidoc.Save
uidoc.close
set uidoc = ws.EditDocument( true, note )
0
 
LVL 5

Author Comment

by:snocross
ID: 7016347
Well the problem is I can't even get that far... when I put this code in my lotusscript I get an IS NOT A MEMBER: CREATERICHTEXTITEM error I think because it's a UI document:

Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")

Here is my section of code:

REM Create link and post on project document
     Dim work As New NotesUIWorkspace
     Dim CurrentDoc As NotesUIDocument
     Dim rtitem As NotesRichTextItem
     
     Set CurrentDoc = work.CurrentDocument
     Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")
     
     Call rtitem.AppendText("This is a link to a database template created for this project:")
     Call rtitem.AddNewLine(1)
     Call rtitem.AppendDocLink( NewDb, "Test" )    
     
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7016393
CreateRichTextItem is a NotesDocument method, it is not UIDocument method.

If you have the field called ProjectLink, then use
set rtitem = CurrentdDoc.GetFirstItem("PriojectLink")

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Expert Comment

by:zvonko
ID: 7016404
Hello Sno,

here I have done something simelar:
http://www.experts-exchange.com/jsp/qShow.jsp?ta=lotusnotes&qid=20290601

Therin you see that instead using frontend document object you have to use the asociated backend document (as Heman proposed).
Them main problem is that RichText fields are not rendered to fronted until saved to disk, fronted document closed and opened again. That's the problem.

Change your code like this:
REM Create link and post on project document
  Dim work As New NotesUIWorkspace
  Dim CurrentDoc As NotesDocument 'no UI
  Dim rtitem As NotesRichTextItem
 
  Set CurrentDoc = work.CurrentDocument.Document 'extended
  Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")
 
  Call rtitem.AppendText("This is a link to a database template created for this project:")
  Call rtitem.AddNewLine(1)
  Call rtitem.AppendDocLink( NewDb, "Test" )    
....

You see?

0
 
LVL 5

Author Comment

by:snocross
ID: 7016439
Zvo, I tried your code but I get the error "RTITEM ProjectLink already exists" on the following line of code:

Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")

NOTE: I have a preexisting editable rich text field called ProjectLink
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7016461
Do all RTItems with Backend...

I prefer Zvo's following approach !

Set CurrentDoc = work.CurrentDocument.Document

Hi Bro!


0
 
LVL 5

Author Comment

by:snocross
ID: 7016467
Zvo, I tried your code but I get the error "RTITEM ProjectLink already exists" on the following line of code:

Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")

NOTE: I have a preexisting editable rich text field called ProjectLink
0
 
LVL 5

Author Comment

by:snocross
ID: 7016472
Heman, I tried plugging your rtitem code into Zvo's and it eliminated the error but the doclink never appears on the document even after closing and reopening:

REM Create link and post on project document
     Dim work As New NotesUIWorkspace
     Dim CurrentDoc As NotesDocument 'no UI
     Dim rtitem As NotesRichTextItem
     
     Set CurrentDoc = work.CurrentDocument.Document 'extended
     'Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")
     Set rtitem = CurrentDoc.GetFirstItem("ProjectLink")
     
     Call rtitem.AppendText("This is a link to a database template created for this project:")
     Call rtitem.AddNewLine(1)
     Call rtitem.AppendDocLink( NewDb, "Test" )    
     Call CurrentDoc.Save( False, True )


Hello Arun!
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7016510
You have now two options:
1: recreating the RT item by removing the present one and create a new item whit same name.
2: fetch the present RT item and append text.

Take care that in second way you have to declare the rtitem as Variant, like this:
Dim rtitem As Variant
Set rtitem = CurrentDoc.GetFirstItem("ProjectLink")
If ( rtitem.Type = RICHTEXT ) Then ...

If you prefer the recreation method then simply call the Remove method:
Dim rtitem As NotesRichTextItem
Set CurrentDoc = work.CurrentDocument.Document
Call CurrentDoc.RemoveItem("ProjectLink")
Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")


0
 
LVL 10

Expert Comment

by:zvonko
ID: 7016567
Hello Sno,

how about this:
Sub Click(Source As Button)
  Dim work As New NotesUIWorkspace
  Dim uidoc As NotesUIDocument
  Dim CurrentDoc As NotesDocument
  Dim rtitem As Variant
  Dim NewDb As NotesDatabase
  Set uidoc = work.CurrentDocument
  Set CurrentDoc = uidoc.Document
  uidoc.Close
  Doevents
  Set NewDb = CurrentDoc.ParentDatabase
  Set rtitem = CurrentDoc.GetFirstItem("ProjectLink")
  If (rtitem Is Nothing) Then Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")
  If ( rtitem.Type = RICHTEXT ) Then
    Call rtitem.AppendText("This is a link to a database template created for this project:")
    Call rtitem.AddNewLine(1)
    Call rtitem.AppendDocLink( NewDb, "Test" )
    CurrentDoc.Form = "ProjectDoc"
    Call CurrentDoc.Save( False, True )  
  End If
  Set uidoc = work.EditDocument(EditMode, CurrentDoc)
  CurrentDoc.SaveOptions = "0"
End Sub

Does it work for you?

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7016877
Sno, after saving the changes to the document you have to reopen the document by closing the current one.

Set uidoc = work.EditDocument(EditMode, CurrentDoc)
 in zvonko's script also does the same trick.
0
 
LVL 10

Accepted Solution

by:
zvonko earned 200 total points
ID: 7016916
Thank you Heman for cut'n pasting my code :-)
Without this I would not notice that EditMode was not defined!

Here the correct version:
Sub Click(Source As Button)
  Dim work As New NotesUIWorkspace
  Dim uidoc As NotesUIDocument
  Dim CurrentDoc As NotesDocument
  Dim rtitem As Variant
  Dim NewDb As NotesDatabase
  Dim EditMode As Integer
  Set uidoc = work.CurrentDocument
  Set CurrentDoc = uidoc.Document
  EditMode = uidoc.EditMode
  uidoc.Close
  Doevents
  Set NewDb = CurrentDoc.ParentDatabase
  Set rtitem = CurrentDoc.GetFirstItem("ProjectLink")
  If (rtitem Is Nothing) Then Set rtitem = CurrentDoc.CreateRichTextItem("ProjectLink")
  If ( rtitem.Type = RICHTEXT ) Then
    Call rtitem.AppendText("This is a link to a database template created for this project:")
    Call rtitem.AddNewLine(1)
    Call rtitem.AppendDocLink( NewDb, "Test" )
    CurrentDoc.Form = "ProjectDoc"
    Call CurrentDoc.Save( False, True )  
  End If
  Set uidoc = work.EditDocument(EditMode, CurrentDoc)
  CurrentDoc.SaveOptions = "0"
End Sub

Thanks Heman <|:-)



0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7017011
Anytime pal.
0
 
LVL 5

Author Comment

by:snocross
ID: 7017223
Thank you very much everyone, this did the trick!  It was very frustrating yet it seemed so simple.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7017280
When we did not fix that, who else should then :-)

0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7017485
;-)

There is a nice saying in tamil...

ippadai thorkin yeppadai vellum....
Meaning,
If this army loses which will win ???

:-)
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7019597
Right! :-)

The words sound good Arun; if I where not so lazy I would learn Tamil.

My fathers second sun (my brother :-) is learning Thai. He can even write this strange letters!
(and read it afterwards :-)

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question