On save of a document I’m running SSJS that is doing a .save() and then I am wanting to include the document link (URL) in the body of a notification email that gets sent by using context.getUrl().
This works for documents that are already saved because it has the doc id in the URL when doc gets opened, but not for new docs. Is there a way I can accomplish this for new documents that do not have their ID yet?
You have to construct the URL yourself since (as you already know) the context.getUrl() method can not be used.
So after your .save() you could do something like the following:
The
context.getUrl().toString().split(view.getPageName())[0]part should give you the hostname and database filepath according to David Leedys xpagescheatsheet.com URL test. I then add the current XPage name and the openDocument and docid parameters.