MA

    I have a report (output is .doc), and at the end of its output file I want to display contents of other file(.doc), that is stored on a server.

Which function does this and how?

by Torsten Haase
Posted on Fri, 04/13/2012 - 09:50

Hi Misha,

using the latest service release (SR03 / 2012), you can read a stored doc file and insert it into another output document.

Create your output document using our new output object:

Context.setProperty("use-new-output", true)
var output = Context.createOutputObject()
...write something into output object or jump to a mergefield

You can read a document (.doc) using

Context.getOutputObject("any name ending with .doc", byte[] (the file content))

...returning an "ExtendedOutputObject". Example:

var docToInsert = Context.getFile("storedDocument.doc", Constants.LOCATION_SCRIPT)
var myOutputObjToInsert = Context.getOutputObject("whatever.doc", docToInsert)

Insert it into your output document:

output.InsertDocument(myOutputObjToInsert, false, false)
output.WriteReport() //finish

Best regards,

Torsten

 

 

0
by Nikolai Zorin
Posted on Thu, 06/07/2012 - 09:50

Hi Torsten,

I have two questions:

1.

I'm on 7.2.3.631018, the code I try is as follows:

 

var oOutput = Context.createOutputObject() ..... var aFile = Context.getFile("file.docx", Constants.LOCATION_COMMON_FILES) var oObj = Context.getOutputObject("BRD-ARIS.doc", aFile)         oOutput.InsertDocument(oObj, false, false) oOutput.WriteReport()   Error message I got is "Cannot find function InsertDocument in object OutputObject XXXXX..." What can be the problem? Any library missing?

2.

 How to convert user-defined path into a valid parameter for getFile? 

 

Regards,

Nikolai

0
by Kaushik Mishra
Posted on Tue, 08/05/2014 - 00:40

In reply to by thaase

Hi Torsten,

Can we insert an excel file into a Doc file using InsertDocument ?

Regards,
Kaushik

0
by Misha Akopov Author
Posted on Fri, 04/27/2012 - 15:39

Mr. Torsten Haase

 

Thanks for replay ! I learned muuch from your post .

 

Now I want to copy one file to another directory , and I couldn't do it. Can you give me hint ? 

For example I have file D:\a.doc  and I want to have it on C:\  how can I do that ? I tried to do it with Java library , but

    new java.io.FileOutputStream("D:/a");

says :

  Wrapped java.io.FileNotFoundException: D:\a.doc (The device is not ready)

the same is with new java.io.FileInputStream(f);

Is there in ARIS API functions to copy a file ? 

 

P.S. wich version of java libraries is  used in ARIS SCRIPT ?

 

Thanks a lot

0
by Torsten Haase
Posted on Fri, 04/27/2012 - 16:34

Hi Misha,

the java library version is the same that is used by the rest of the server. Should be at least 1.5.

Be very careful when dealing with files in a report, because a report is executed on the server side. This is your local machine only in LOCAL or localhost scenario. In the 'normal' case of use you use a remote server and you cannot know the file system structure or user permissions on the server. This may lead to the described error.

BR,



Torsten

0
by Misha Akopov Author
Posted on Mon, 04/30/2012 - 08:29

Thanks Mr. Torsten Haase, now I know the reason of the error. There is no other solution, I have to copy files to local machine... Can you tell me how to copy them on local machine and not to Server ?

0
by Edwin Verstraeten
Posted on Tue, 05/01/2012 - 13:12

Hi Misha,

You could try to FTP to your local machine using the Context.Execute method.

Best regards,

Edwin

0
by Edwin Verstraeten
Posted on Fri, 06/08/2012 - 09:16

Hi Nikolai,

You can use the regular java.io.File class in order to create the byte array.

Best regards,

Edwin

0
by Torsten Haase
Posted on Mon, 06/11/2012 - 09:31

Hi Nikolai,

1) You make use of the extended output object here. In order to make "createOutputObject" create an extended output object, you have to insert the following line before calling "createOutputObject" until the extended output object becomes the standard:

Context.setProperty("use-new-output", true)

2) you should avoid direct access to the file system in report scripts, so the best way is to have your "template file" "BRD-ARIS.doc" stored either in the report script's category or in "Common Files".



Best regards,

Torsten

0
by Nikolai Zorin
Posted on Wed, 06/13/2012 - 02:10

Hi Torsten,

many thanks for clarification on first issue. 

Regarding the second one:

a. What is the problem getting file form the file system and inserting it into the ARIS report? Is there way to do it sourcing file path from AT_EXT_1 attribute or from user dialog?

b. Can I source binary object from AT_DOCUMENTATION? What would be the correct syntax for this insertion?

Thanks and Regards,

Nikolai

 

 

0
by Edwin Verstraeten
Posted on Mon, 06/11/2012 - 10:29

Hi Torsten,

Fully agree to your statement that you should prevent direct access to the file system, but in some cases it's necessary. I have used an xml input to be combined with ARIS content, and the report had to run scheduled, so I had no option but directly access the filesystem.

Best regards,

Edwin

0
by Torsten Haase
Posted on Wed, 06/13/2012 - 09:59

Hi Nikolai,

a.1) the problem would occur when you use ARIS in a multi-server scenario. In this case you cannot determine, from which server's file system the file would be read.

a.2) using AT_EXT_1 would not help much, because it contains only a file system link which would cause the same issue as (a.1)

a.3) using a user dialog you can browse the client's file system. The function Dialogs.getFilePath returns the file content, which can be processed by your report

b) Yes, you can access the content of AT_DOCUMENTATION from the report easily. The following piece of code shows you how:

        var attrDoc = obj.Attribute(Constants.AT_DOCUMENTATION,Context.getSelectedLanguage());
        if(attrDoc.IsMaintained()){
            var bytearray = attrDoc.getExternalDocument().getDocument();
            var docVal = Context.getOutputObject("tmp.doc",bytearray);
            // this would insert the AT_DOCUMENTATION content into another document:
            mainOutputObject.InsertDocument(docVal,false,false);
            // this potentially saves memory:
            docVal = null;
        }

Best regards,

Torsten

0
by Nikolai Zorin
Posted on Thu, 06/14/2012 - 09:56

Thanks Torsten, You're star.

I'm still looking for option to source file using path. We have common shared drives and SharePoint so multi -server ARIS environment should not be a problem.

Dialog option definitely works, but in my case I can provide fixed link in AT_EXT_1. Is there way to get file from this location ( not predefined in Constants) not using dialog? May be I can suppress dialog somehow?    

Developing the topic I have some more questions:

1. What is the use of "Parameter X" attribute for Link X?

2. How to make script to write into existing doc file. I mean having doc template with tags which will be replaced with information from ARIS.

Thanks.

Nikolai

0
by Kaushik Mishra
Posted on Tue, 08/05/2014 - 01:01

Hi Torsten,

Can we insert an excel file into a Doc file using InsertDocument ?

Regards,
Kaushik

0
by Kaushik Mishra
Posted on Tue, 08/05/2014 - 01:44

Hi,

var docToInsert = Context.getFile("ProcedureReport.doc", Constants.LOCATION_SCRIPT)
var myOutputObjToInsert = Context.getOutputObject("tmp.doc", docToInsert)
oOutput.InsertDocument(myOutputObjToInsert, false, false)
oOutput.WriteReport()

But I am getting an error "Cannot create output object.Cannot create document"

Kindly need your help to understand where I have gone wrong?

Regards,
Kaushik

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock