Profile picture for user martin.miskovic

Greetings everybody,

I am trying to send an e-mail with attachment from Aris. I am using this class:

http://www.ariscommunity.com/users/amol/2011-10-11-how-send-email-using-aris-script

Problem is that I can not determine the path for the report file output. I work with XlsWorkbook class that has no method to get a path to the file. Report seems to be working with the file in temp directory, where I can't figure out where the file is saved.

I can change the final destination of the output, but this will save workbook at the end of the script runtime. Meaning I would have to create one report to export data into the file and the other to send this saved file via e-mail message.

Any ideas will be appreciated. Thank you.

Martin

by Ilya Seletkov
Posted on Tue, 07/21/2015 - 07:05

Hello!

Try to do following:

//Folder and name of the file to be attached (on the server)
sFolder = "C:\Temp\";
sFileName = "Attachment.xls";

//Creates Excel
oExcel = Context.createExcelWorkbook ( sFileName );
//Add content
oExcel.write(); //Writes to output location.


//Bytes array of the file.
oData = Context.getFile (sFileName, Constants.LOCATION_OUTPUT);

//save to your work folder on server 
oFile = new java.io.File(sFolder+sFileName);
oOS  = new java.io.FileOutputStream(oFile);
oOS.write(oData);
oOS.close();

And now you can use file sFolder+sFileName in the JavaMail.

Hope, this helps.

BR, Ilya.

 

0
by Martin Miskovic Author
Posted on Mon, 08/03/2015 - 14:37

Thank  you very much for your help Ilya.

Martin

0
by Yuriy Stolyarov
Posted on Thu, 11/26/2020 - 16:03

Hello
I am trying to change the save location of the report file.
But in my case I am using the xml file
I try to do this:

function outputFileToFolder( folderName, fileName, oData ) {
     var oFile = new java.io.File(folderName+fileName);
     var oOS  = new java.io.FileOutputStream(oFile);
     oOS.write(oData);   // Error: nullPointerException, because oData is empty
     oOS.close();
  }

function main() {
var xmlOutput = Context.createXMLOutputObject(Context.getSelectedFile(), "Root");

//then I fill the file with content using methods "addElement" and "setAttribute"

//at the end I do this:
Context.addOutputFileName ("101.xml");

xmlOutput.WriteReport();     // it's default folder

var oData = Context.getFile("101.xml", Constants.LOCATION_OUTPUT);  // <- oData  // is null, because file "101.xml" not apeared in default folder

outputFileToFolder( "C://TEMP//output", "Data.xml", oData );  // it's my folder
}

But I get error nullPointerException.
Tell me please how can I solve this problem?

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