Basics of MODLR Process Development

Ivan Kulman -


 The basics of MODLR process development

Welcome to the first article in the MODLR Development series. In this article we’re going to have a look at the structure or a MODLR process and some basic debugging and output functions.

MODLR processes use JavaScript as programming language with support for standard JS function as well as MODLR specific functions.

JavaScript is the most commonly used programming language in the world and it is used for 90% of current websites.

If you would like to learn more about JavaScript, you can use these websites:

If you prefer a more structured approach, there are several online instructor-led courses provided by these organisations:

Now, back to MODLR!

Each MODLR process has 4 basic steps predefined and they serve the following purpose:

  • Pre - executed before the process and is used for on-screen prompts
  • Begin - executed once before the data load
  • Data - executed once for every record in the data set
  • End - executed once after the data load

Another important thing to know about MODLR development is the concept of variable scopes.

Each variable defined in a function is only available in that function and that function only.

For example, a variable defined in the Begin function is not visible in the End function, therefore the following code will result in an undefined variable error.

function begin() {
    var variableName = "Variable Value";

function end() {

If you would like to have a global variable such as storing a cube name into the variable “cubeName”, then it needs to be defined outside of the four main functions:

var variableName = "Variable Value";

function begin() {

function end() {

During the tutorial series we'll use several inbuilt MODLR functions and code techniques.

The most basic one is referencing incoming data source columns: record[“columnName”]

And another two which are absolutely necessary for good development:

console.log(object); //This logs the object variable in the browser console

script.log("Test"); //This logs "Test" in the MODLR System and can be accessed via the Logs page.

To round up this article, let's code a process that outputs the number of dimensions in the specified cube. As discussed previously, there four predefined functions in MODLR.

Let’s take a closer look at what we’re going to do and how to achieve this.

Firstly, we need to get the cube name from the user who is running the process, so we’ll need a prompt. Prompting code is executed in the pre function.

Then, we’ll get check if the cube exists and if it exists indeed, we’ll output the cube name with its dimension number. If the cube doesn’t exist, the log message should let us know about this.

Prompting uses the function script.prompt, which initialises a global variable, meaning there’s no need to define it later in the code. We need, however, to define the output string as a global variable because it will be used in different functions.

Then in the begin function we check if the cube exists and modify the output string accordingly.  Last but not least, the end function will output the result using the “script.log” function.

var logOutput = "";

function pre() {
    script.log('process pre-execution parameters parsed.');
    script.prompt("Cube Name","cubeName","");

function begin() {
    script.log('process execution started.');
        var dimensions = cube.dimensions(cubeName);
        logOutput="Cube :"+ cubeName +" exists and has the following dimensions:" + dimensions;
    else {
        logOutput="Cube :"+ cubeName +" does not exist";

function data(record) {


function end() {
//this function is called once at the end of the process
    script.log("script.log: " + logOutput);
    script.log('process execution finished.');

Let’s run the process and see how it behaves. First, the prompt is displayed where you can enter a cube name:


For the first attempt, I am going to use a cube name that does not exist - “Nonexistent Cube”, then click “Confirm Execution”.

At this stage MODLR automatically redirects us to the logs page, where we can find this log record:


Let’s try a different cube name: “General Ledger”. In this case the process output is different, the process is logging all dimensions in the “General Ledger” cube.


Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk