Doclink not opening in xpages

144 views Asked by At

i am using this code it is show doclink but it is not opening it show some error.

var document1:NotesDocument = database.createDocument();
var rtitem:NotesRichTextItem = document1.createRichTextItem("body");
document1.replaceItemValue("Form", "memo");
document1.replaceItemValue("SendTo", "[email protected]");
document1.replaceItemValue("Subject", "Rajesh");
rtitem.appendText("Some text here... ");
rtitem.addNewLine(2);
rtitem.appendText("NotesDocument.NotesURL");
rtitem.appendDocLink(document1, "Some comment text");
rtitem.addNewLine(2);
document1.save();
document1.send(); 

Error:- enter image description here enter image description here

Please tell me how to open a doclink.

1

There are 1 answers

0
Knut Herrmann On BEST ANSWER

I guess you want to create a link to XPage's current document in your email.

You might have a data source defined in your XPage which is named "document1" as default

<xp:this.data>
    <xp:dominoDocument
        var="document1"
        action="editDocument"
        ...
    </xp:dominoDocument>
</xp:this.data>

Then, your code would look like this:

var documentMail:NotesDocument = database.createDocument();
var rtitem:NotesRichTextItem = documentMail.createRichTextItem("body");
documentMail.replaceItemValue("Form", "memo");
documentMail.replaceItemValue("SendTo", "[email protected]");
documentMail.replaceItemValue("Subject", "Rajesh");
rtitem.appendText("Some text here... ");
rtitem.addNewLine(2);
rtitem.appendText("NotesDocument.NotesURL");
rtitem.appendDocLink(document1.getDocument(), "Some comment text");
rtitem.addNewLine(2);
documentMail.save();
documentMail.send();

I changed email document's object name to documentMail and added .getDocument().
document1.getDocument() gives the data sources' document.