Hallo,
I have a problem when I create a report at ARIS 9.8.
I was upload file to Document Storage link. And I tried to create script but it's not work. Because script error.
var attrDoc = dataofModels5[z].Attribute(Constants.AT_ADS_LINK_1,nLocale);
if (attrDoc != "Attr[4015,[Binary data], locale=1033]@0") {
p_output.BeginSection(false, Constants.SECTION_DEFAULT)
sectionPageSetup2( xx, p_output )
var bytearray = attrDoc.getExternalDocument().getDocument();
var docVal = Context.getOutputObject(file,bytearray);
p_output.InsertDocument(docVal, false, false);
p_output.EndSection()
Does anyone know how to get output file in document storage link??
Please help me. and thank you for your attention.
Unfortunately this seems to be a complicated topic.You can't use getExternalDocument() because the ADS is protected by authentication mechanisms. getExternalDocument is useful when you try to retrieve a document from a normal file system, like a shared network drive.
To retrieve files from the ADS you have to load the ADS report component and use that to get your file. Unfortunately the ADS report component only provides the file content as a Java InputStream, which makes things quite complicated.
Here is a very crude, but working approach. Feel free to improve it as much as possible.
var nLocale = Context.getSelectedLanguage(); var oOutput = Context.createOutputObject(); var selModels = ArisData.getSelectedModels(); var adsComponent = Context.getComponent("ADS"); for each(var mod in selModels){ var adsAttr = mod.Attribute(Constants.AT_ADS_LINK_1, nLocale); var adsLink = adsAttr.getValue(); var adsDocument = adsComponent.getDocumentByHyperlink(adsLink); var adsTitle = adsDocument.getDocumentMetaInfo().getFileName(); var adsInputStream = adsDocument.getDocumentContent(); var tempFile = java.io.File.createTempFile("temp", null, null); tempFile.deleteOnExit(); var fileOutputStream = java.io.FileOutputStream(tempFile); while(adsInputStream.available() > 0){ fileOutputStream.write(adsInputStream.read()); } var bytes = java.nio.file.Files.readAllBytes(tempFile.toPath()); var adsExtendedOutputObject = Context.getOutputObject(adsTitle, bytes); oOutput.InsertDocument(adsExtendedOutputObject, false, false); } oOutput.WriteReport();
Note here: I seriously hope that java.io.File.createTempFile(...) and tempFile.deleteOnExit() work as intended. It would be super bad if this would somehow leave remnants on the ARIS server, clogging the system.
Edit: after getting the byte array with java.nio.file.Files.readAllBytes(...) you can also call tempFile.delete() to delete the temp file. This ensures there won't be temp files piling up on your server.
I wrote this script and tested it with a patched version of ARIS 10.0.7. Can you tell me which ARIS version you're using?
May also be worth checking your report script help documentation for available Methods:
^ Those are the methods available for me. Follow the path on the left side to those classes and take a look.
We've had ARIS 9.8 in the past, but since then we've already had ARIS 10.3 and now ARIS 10.7, so it's been a while since I've used your ARIS version, sorry.
Can you use the search function in the top right corner of your script help to just search for "ADS", "document storage" or similar terms and see whether anything interesting pops up?
I must also correct myself, .getExternalDocument() can seemingly only be used to retrieve the document of the "Documentation" attribute, nothing more and nothing less (at least that's the methods capability here in ARIS 10.7). Anyways, I highly doubt that's the correct method. Maybe something else catches your eye in the script help?
oh it's ok,, never mind...
yappp I found a function "External HTML Document", i don't know what the function is yet, but it's interesting for me, and i will try it. Do u know about this function??
If anyone knows, please share with me.
Thank you for your attention..