Christian
I am having trouble using buildAttachmentTemplateSource .. below is my code .. if I use the line that is commented and a resource that is added to the database .. the code works .. however I cannot get the buildAttachmentTemplate to work. The ID passed via the scope variable is valid (see results at the bottom of this message) .. I can access the document using the same document ID and view as passed to the poiBean and can retrieve a list of the placeholder fields that are in the document. I plan to use this list to build the list of bookmarks. The Word document is contained with a Rich Text field "rtfAttachment" within the document (see attached jpg).
I have tried multiple variations of the database field .. with full server and database name .. without server (just database name) and without both (since the view is in the same database as the REST service) .. all give a null stream
Any help/ thoughts/ suggestion as to what I am doing wrong would be appreciated.
====================== Code of REST Service
try {
//var template = poiBean.buildResourceTemplateSource(null,"IME_CONFIRMATION_LETTER3.docx");
var strPOIDbName = @Name("[CN]", @Subset(@DbName(), 1)) + "!!" + applicationScope.dbNameEVT
print ("POIDBName: " + strPOIDbName);
var strDocId = sessionScope.DocId;
print ("DocId: " + strDocId);
var astrItems = DbLookupArray("", "", "session", "unique", "sort", "vwDocProById", strDocId,"txtDocFields_List","[FAILSILENT]");
print("Items:" + astrItems[0]);
var template = poiBean.buildAttachmentTemplateSource("","vwDocProById", strDocId,"rtfAttachment");
var lstBM = new java.util.ArrayList();
lstBM.add(poiBean.buildDocumentBookmark("dteCreated", "07-Dec-2013"));
lstBM.add(poiBean.buildDocumentBookmark("name", "Trevor Denner"));
lstBM.add(poiBean.buildDocumentBookmark("PatientName", "Trevor Denner"));
lstBM.add(poiBean.buildDocumentBookmark("PatientAddress", "21383 Fultonham Circle"));
lstBM.add(poiBean.buildDocumentBookmark("PatientCSZ", "Ashburn, VA 20147"));
lstBM.add(poiBean.buildDocumentBookmark("Claim Number", "134579"));
lstBM.add(poiBean.buildDocumentBookmark("PatientInjuryDate", "04-Aug-2012"));
lstBM.add(poiBean.buildDocumentBookmark("PayorFirm", "Nationwide Insurance"));
lstBM.add(poiBean.buildDocumentBookmark("ApptDate", "03-Jan-2014 2:15pm"));
lstBM.add(poiBean.buildDocumentBookmark("DoctorName", "James DiTaranto"));
lstBM.add(poiBean.buildDocumentBookmark("DoctorAddress", "Landsdown somewhere"));
lstBM.add(poiBean.buildDocumentBookmark("DoctorCSZ", "Ashburn, VA 20147"));
var result = poiBean.processDocument2Stream(template, lstBM);
if (result == null) {
print("*** ERROR *** Stream Null");
}
return new java.io.ByteArrayInputStream(result.toByteArray());
}
catch (errRaised){
print (errRaised);
}
======================= Console Output
[40F4:000B-30F4] 12/09/2013 11:50:53 AM HTTP JVM: DocId: DO08-9E7NB6
[40F4:000B-30F4] 12/09/2013 11:50:53 AM HTTP JVM: Items:dteCreated PatientName PatientAddress PatientCSZ ClaimNumber Pa
tientInjuryDate PayorFirm ApptDate DoctorName DoctorAddress DoctorCSZ DoctorPhone PayorContact PayorFax AttorneyName Att
orneyFax
[40F4:000B-30F4] 12/09/2013 11:50:53 AM HTTP JVM: *** ERROR *** Stream Null
[40F4:000B-30F4] 12/09/2013 11:50:53 AM HTTP JVM: com.ibm.jscript.InterpretException: Script interpreter error, line=30, col=56: 'result' is null>