Search code examples
xpagesxpages-ssjs

How to Email include Notes link to open xpages client


I have problem when sending a notes link to an email in order to open it directly from email client. Does the link i created is invalid? May i know which is a correct way of sending notes link open xpages page?

Question 1. How to open Document in xpages with document ID by clicking notes link?

one way: i understand is at the form Display xpages. May i know still got other way to do it?

enter image description here

Question 2. How to open Xpages Page without document ID for example is like the page that contain view.

My doclink is write as:

var doclink="notes://"+server+"/"+dname.replace(/(\\)/g, "/")+"/"+document1.getDocument().getUniversalID()+"/Request_Form.xsp?OpenXpages"

result come out for that link: enter image description here

My viewlink is write as:

var viewlink ="notes://" +server+"/"+dname.replace(/(\\)/g, "/")+"/"+"Request_View.xsp?OpenXPage"

result come out for that link: enter image description here

My server and database name as below

enter image description here

Below will be my script of sending email

var setdoc:NotesDocument = database.getProfileDocument("System Setting", "");
var server = setdoc.getItemValueString("MailDBSvr");
var dname = setdoc.getItemValueString("MailDbPath");
var web = setdoc.getItemValueString("InternetAddress");


var maildoc:NotesDocument = database.createDocument()//mdb.createDocument()  //database.createDocument()
maildoc.replaceItemValue("Form", "Memo");
maildoc.replaceItemValue("Subject","Request for Email Account By "+document1.getItemValueString('Name'));
session.setConvertMime(false);
var stream = session.createStream();
stream.writeText("<html><body>");

stream.writeText("<p>Dear " + "department reviewer" + ",</p>");
stream.writeText('<p>Kindly review this request by '+document1.getItemValueString('Name')+" on "+I18n.toString(@Today(), 'dd/MM/yyyy')+ ",</p>");

//  open in web (http://devsvr1.pcs.com.my/CN=ServerOne/O=dev!!Brooke%5CBrooke.nsf/Request_Form.xsp?databaseName=CN=ServerOne/O=dev!!Brooke%5CBrooke.nsf&documentId=5FBA577C3DF795AB4825819400274B0A&action=editDocument)
stream.writeText("<p>Please click "+"<a href='http://"+web+"/"+
database.getServer()+"!!"+
XSPUrl.encodeParameter(dname, "UTF-8") +
"/"+"Request_Form.xsp?databaseName="+server+"!!"+
XSPUrl.encodeParameter(dname,"UTF-8") +
"&documentId="+document1.getDocument().getUniversalID()+
"&action=editDocument'>here</a> to open requisition form</p>")


//  open in notes client (notes://server/path/database.nsf/pagename.xsp?openXpage)
var doclink="notes://"+server+"/"+dname.replace(/(\\)/g, "/")+"/"+document1.getDocument().getUniversalID()+"/Request_Form.xsp?OpenXpages"

stream.writeText("<p><a href='"+doclink+"'>Click Here</a> if you are in the Notes Client. Thank you.</p>");

stream.writeText("<p>Or</p>");

//  open in web (http://devsvr1.pcs.com.my/brooke/brooke.nsf/Request_View.xsp)

stream.writeText("<p>Click <a href='http://"+web+"/"+dname.replace(/(\\)/g, "/")+"/"+"Request_View.xsp?'>here</a> to view all requisitions.</p>");

//  Open in notes Client
//  @URLOpen("notes://server/Path/database.nsf/XPageName.xsp?OpenXPage")
var viewlink ="notes://" +server+"/"+dname.replace(/(\\)/g, "/")+"/"+"Request_View.xsp?OpenXPage"

stream.writeText("<p><a href='"+viewlink+"'>Click Here</a> if you are in the Notes Client. Thank you.</p>");

stream.writeText("<p> ***THIS IS AN AUTOMATED MESSAGE - PLEASE DO NOT REPLY DIRECTLY TO THIS EMAIL***</p>");

stream.writeText("</body></html>");
var body = maildoc.createMIMEEntity("Body");
body.setContentFromText(stream, "text/html;charset=UTF-8", 1725);
stream.close();
maildoc.closeMIMEEntities(true);
session.setConvertMime(true);

maildoc.replaceItemValue("SendTo",document1.getItemValue("Dep_rev"));       

maildoc.send(); 
document1.getDocument().computeWithForm(true,true);

New update: enter image description here


Solution

  • You need to change the way you handle the server name. Notes URLs don't use the full canonical name for servers.

    So change CN=ServerOne/O=Dev to something the notes:// protocol does support. You could use:

    • the shortened name ServerOne%2FDev (use @Name[Abbreviate] and replace / with %2f)
    • the Common name ServerOne (use @Name[CN])
    • the DNS name www.yourserver.com
    • the IP address: 165.34.11.34

    In all cases you need to make sure that the server name gets properly resolved by the Notes client:

    • For the shortened name a connection document would do the trick (unless its the default server, then it is auto).
    • For the Common name it is either a connection document or the DNS resolved it (intranet DNS)
    • for the DNS name, its DNS (doh)
    • You really don't want to use IP addresses, but you could

    Hope that helps