Hello everyone
My customer asks me if it's possible to print an attached file in a report when running a report in a model. I tried to do it from both ARIS Connect and ARIS Architect without success.
I would like to check the feasibility of that. Here's what I did on my own with an example. I first took this model from the Unified Motor Group database
Then selected the attribute Documentation on the Human Resources box and uploaded a test file (.docx)
I had no results so I uploaded the same file on the ARIS Repository
But at the time of running reports, I got the same results (no attached file is considered for the output file)
Is it feasible? is it possible to get the attached file on a final report when running a report?
Thank you in advance for your help
Best regards
Pedro.
is it possible to get the attached file on a final report when running a report?
Yes, it is possible to inline the content other documents in the report result. HOWEVER:
- It requires in depth Javascript and ARIS Script knowledge
- it's requires a little bit of tinkering
- I have no idea at which point to insert the code snippet I can give you into the "Generate job description" report, simply because that's not a report with whose structure I'm familiar
- It only works with the original output format being doc, docx, rtf, odt, pdf and plain text AND the document you want to inline being rtf, doc/dot or docx
- The file to inline has to be at some place the ARIS server (where reports are executed) can reach, like a public working directory for example. Storing the file at some place that requires special access permissions, permissions which the server usually does not have, will produce errors
Here is what I've put together, really just quickly coded this, no trying things and catching exceptions (report context: can only be executed with objects > functions. Should work with other objects that have the link attribute too though):
var nLocale = Context.getSelectedLanguage(); //need that to read the attribute value of the link attribute var selObjDefs = ArisData.getSelectedObjDefs(); //just to get what we work with var p_output = Context.createOutputObject(); //create a new output object p_output.DefineF("Standard", "Arial", 11, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0, 0, 0, 0, 0, 0); //Define a standard output format main(); //no need to clutter the global name space p_output.WriteReport(); //write the report at the end of the script function main(){ //the main method p_output.OutputLnF("Beginn inline", "Standard"); //Write a line to show that we are still in the original output object p_output.OutputLnF("", "Standard"); //and an empty line for each (var oneObjDef in selObjDefs){ //for each object var documentPath = oneObjDef.Attribute(Constants.AT_DOCUMENT_LINK_1, nLocale).getValue(); //obtain the file path that was written into the Document Link 1 attribute var byteArray = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(documentPath)); //Create a byte array with the file from path just obtained var docVal = Context.getOutputObject("tmp.docx",byteArray); //create a second output object, with the byte array as the content docVal.SetDistFooter(p_output.GetDistFooter()) //Set up the new output object to be just like the original one docVal.SetDistHeader(p_output.GetDistHeader()) //"" docVal.SetBottomMargin(p_output.GetBottomMargin()) //"" docVal.SetTopMargin(p_output.GetTopMargin()) //"" docVal.SetLeftMargin(p_output.GetLeftMargin()) //"" docVal.SetRightMargin(p_output.GetRightMargin()) //"" p_output.InsertDocument(docVal,true,true,Constants.INSERT_DOC_REMOVE_TOC_AND_PAGEBREAK); //inline the second output object into the first one docVal = null; //remove any trace of the second output object with the next garbage collection } p_output.OutputLnF("End inline", "Standard"); //Just to show that we are back in the main output object }