Volker Eckardt's picture

In this additional article we will collect general findings, best practice and further notes to make your life easier when writing JavaScript reports  (see this Part 2 - Tutorial)

General

  • Creating reports in JavaScript can give a lot of fun, but keep in mind that such reports are difficult to maintain and you may need an experienced ARIS JavaScript writer to change code later on.
  • If you touch a generated code, the Layout Editor (WYSIWYG) will go immediately away. Stay therefore as long as you can inside the Layout Editor, and only in case that there is no other chance, start with JavaScript writing.
  • Backup your development results regularly (via Export)

Pure JavaScript Notes

  • JavaScript is case sensitive
  • A variable has to be defined; you can define it everywhere in the code by using the var command.
  • Make yourself comfortable with java types like strings, lists, compare operations, etc. All of them are helpful and you may need one of these earlier then expected.
  • Use custom functions to store code centrally and make it reusable, you also may use the import functionality to access code elements already written
  • A function has not to give back a return value (but can)
  • You may create your own JavaScript classes right in your code (will discuss this in the Dialog Tutorial)

ARIS JavaScript

  • Global objects like ArisMetaModel (Context.getArisMethod()), ArisData, Context etc. are sometimes not available in all environments (reports, macros or semantic check; client or server). Consult the script help to get more details.
  • You can get similar information from different objects (Model name from context or from the current object occurrence)
  • Object names are language dependend, use the function "Context.getSelectedLanguage()" to get the names correctly.
  • The way to initialize Excel output differs from plain text. You need to enhance your code to get data in Excel.
  • Use the String Table to support multilanguage (will be discussed in this tutorial).
     

Best Regards

Volker

Tags: tutorial Report script javascript