Basics of Action Codes

Back

AiM is a facade based application using rhino interpreter as the JavaScript engine. The syntax is a combination of Java and JavaScript.

We use “var” to declare the variables in the action codes. JavaScript treats each variable according to the value defined for the variable. By default, var is treated as a string. If we try to add two numbers using “var i=1;var j=2; print i+j;” , JavaScript prints “12”. It considers the two variables as strings and concatenates them together. We need to define the variables as “var i=1.0;var j=2.0” to add two numbers.

There are multiple modules in AiM. We have access to all the classes in it. The Facade and the DTO classes will be the frequently used classes. Every table in AiM has a description field. If we need to access a file, we can do it through the repository and use the repository functions. One more option is to use the UDFs.

Types of Action Code:

  • Insert/Before Insert
  • Update/Before Update
  • Template
  • Service
  • Scheduled

“Insert” and “Before Insert” are used when we are saving a new record.  The difference between both of them is that “before insert” happens before the save and “insert” action code runs after the save happens. Similarly for “before update” and “update” action codes. But, prior to running these action code, the system first checks if all the mandatory fields are filled in and then the action code is run. “Template” action code is run when a new record is created. Scheduled action code runs on the timer. We need to choose the date and the frequency for the action code to run.