This is the seventh article in a series provided for non-technical System Administrators who wish to understand more about using JavaScript to control workflow and to implement simple customizations using the language.

In this article, I will explore statements in JavaScript.

A program is a sequence of statements.

Expression Statements

And one of the fundamental types is an Expression Statement. An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value. 

And any expression that can stand alone as a statement is an Expression statement

strMessage = “hello world”;
myBlock = CRM.GetBlock(“noteboxlong”);

Compound Statements

The next type of statement to understand is a compound statement. These are individual statements that logically must be considered together. We group statements like this using braces { the curly brackets }

Consider the differences between these two examples

Example A

strMessage=“Hello World”;

and this one

Example B

strMessage=“Hello World”;

The set of statements in Example A has an "if" condition. An if condition acts as a guard to the following statement. In this case, if the CRM.Mode evaluates to be in View mode then the second line will be processed. If the CRM.Mode does not evaluate to be in View mode then the line will be skipped.

Importantly the second line which sets the mode to be edit will always be carried out.


When we use the braces we are able to say that both statements must be read together. Everything in a compound statement is treated as a single unit of code.

Arithmetic Operators

JavaScript offers the use of different forms of operators that do ‘work’ on data within statements. Arithmetic operators are used for performing arithmetic tasks on numbers (literals or variables).

And when we are working with variables that are different ways of assigning a value to that variable.

We will meet some of these different types as you explore the articles on the community.

In the next article, I will develop the idea of conditional behaviour and compound statements.

An Introduction to JavaScript in Sage CRM

The links to the other articles in the series are listed below

  1. An Introduction to JavaScript in Sage CRM.
  2. The relationship that JavaScript has with other languages and where scripting can be used in practice.
  3. The syntax of the language and the different objects available.
  4. The different types of JavaScript data types and how we use them in Sage CRM scripts.
  5. The objects that are available within the Browser.
  6. Binding a script to an event.
  7. Statements in JavaScript.
  8. Conditional behaviour and compound statements.
  9. Another look at Strings, regular expressions and other objects.
  10. Arrays, Functions, and techniques for processing objects.