One of the great features of XPages is that we can now abstract the code from the data. So we can have the documents that contain attachments in one database and the XPage that contains the code for the Download control in another.
Acknowledgements to Raz Hoe for the lead on this solution. Also to John Mackey for this post. (Important that you read John's article.) I have combined these solutions for those who need their code to work for both the Notes client and the browser, as it took me quite a while to resolve this issue:
This code needs to go in the All Properties section of each Download control:
In my 8.5.2 FP2 production applications I compute the following SSJS for the fileNameHrefValue property:
if (@IsNewDoc()) return "#"; //do nothing if document1 has not yet been saved
if (@ClientType()=="Notes") return "/.ibmmodres/domino/OpenAttachment/"+database.getServer() + "!!"+ sessionScope.mydbName + "/"+document1.getDocument().getUniversalID() + "/attachment/"+rowData.getName();
var serv = session.getHttpURL().split("?");
return serv + "/" + sessionScope.mydbName+ "/0/" + document1.getDocument().getUniversalID() + "$FILE/"+ rowData.getName();
Hope you find this to be useful.