1

Previously i am sending a form as a doclink using @functions

Eg: @MailSend("Mary Tsen/";"";"";"Follow this link";"";"";[IncludeDocLink])

Please tell me how to send a mail message that includes a doclink in XPages using Serverside JavaScript.

thank you

Steve Zavocki
  • 1,840
  • 4
  • 21
  • 35

2 Answers2

4

The concept of a doclink in a web application don't exist. Therefore you must create an email and include a URL to the specific element. Not sure if using XPINC allows adding of a doclink.

email = database.createDocument();
email.replaceItemValue("Form", "Memo");
email.replaceItemValue("Subject","Test");
email.replaceItemValue("Body","You have email");
email.replaceItemValue("SendTo", sendto);
email.send(false);

In the past what I have done to include a link was to reconstruct the URL, as shown below, for the XPage and add that to the body of the message.

I used a viewPanel link for my scenario, but this should get you down the proper path.

var url:XSPUrl = context.getUrl();
var doc:NotesDocument = row.getDocument();
var unid = doc.getUniversalID();
var scheme = url.getScheme();
var host = url.getHost();
var db = database.getFilePath();
pdfurl = scheme + "://" + host + "/" + db + "/0/" + unid;
Dwain Wuerfel
  • 373
  • 1
  • 11
  • XPiNC functions the same as the browser in this case. You'd need to build the URL the same way. In both cases, though, I'd expect that the URL that they want to send would be one to the XPage for displaying the document, not to the Notes document itself. I've not tried using the Form's property "On Open Display using XPage:", so maybe just sending the doclink as in your code would open it in the selected XPage..... – David Navarre Jun 04 '15 at 12:37
1

You can add a doclink to a rich text item using something like the code below.

    var docEmail:NotesDocument = database.createDocument();
    var rtitem:NotesRichTextItem = docEmail.createRichTextItem("Body");

    docEmail.replaceItemValue("Form", "Memo");
    docEmail.replaceItemValue("SendTo", "Your recipient");
    docEmail.replaceItemValue("Subject", "Your Subject");

    rtitem.appendText("Some text here... ");
    rtitem.addNewLine(2);
    rtitem.appendText("Click here to view the document => ");
    rtitem.appendDocLink(thisdoc, "Some comment text");
    rtitem.addNewLine(2);

    docEmail.send();    
Martin Perrie
  • 398
  • 5
  • 16