This is the second 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 want to look at the relationship that JavaScript has with other languages and where scripting can be used in practice.

Let's start by clearing something up. JavaScript is nothing to do with the language Java.

If you have read any of the documentation then you may have seen that some of Sage CRM's features depend on Apache Tomcat.  Apache Tomcat is a "Java" HTTP web server environment for Java code to run. Java is an essential part of the server platform for Sage CRM but it isn't anything to do with JavaScript.

JavaScript is the original name for the script when the language was developed by Netscape. They called it that because 'Java' was another language becoming popular at about the same time. But the two languages don't have a relationship.

Sometimes in documentation and articles on other sites, you may come across a reference to 'ECMAScript'. This is the name of the language standard developed by ECMA, from the original JavaScript implementation. JScript is Microsoft's name of their own implementation.

I will only ever refer to JavaScript in my blogs and although there are some syntax differences between JScript and JavaScript these are not important enough for me to make a distinction here.

In theory, different languages could be used in Sage CRM for different purposes. JavaScript is the default language and is the nearly universally used language. For all intents and purposes, this should be the language that you use for scripting in Sage CRM and the only language you can use for Create, Validate and TableScripts.

JavaScript is processed and executed by a scripting engine and it is the scripting engine that determines the default language used in each circumstance. And within a Sage CRM context that is going to be in either the browser, the application server or in an ASP page.

References for the Scripting Engine to be used to process code that you have written are either implicit or explicit.

In Sage CRM any of the internal code that we write this is the code that is executed in the application server (these are the field level scripts, workflow conditions and the table level scripts) is all implicitly JavaScript.

When we are writing and editing scripting page – ASP pages – for custom entities and other extensions of the system we have to include an explicit reference to the language used.

<%@ CodePage=65001 Language=JavaScript%>

I have covered this in other articles about writing ASP pages. And I plan to write more about basic ASP scripting a little later on this year.

In Screens

If we open up the customization area for a screen like OpportunityDetailBox we can see that each field has 3 separate boxes in which scripts can be entered.

  • CreateScript in which JavaScript can access Serverside objects
  • onChange Script which can refer to Clientside or Browser objects
  • And a Validate Script that again can access Serverside Objects

Serverside objects are references that can be made to the internal code of CRM exposed through the API.

We can also use a script in the custom content boxes of a screen that references Clientside or Browser objects but that is covered in other articles.

In TableScripts

Each main entity can have TableScripts associated with it.

The image below shows a TableScript that has been added for the company entity.

You can see that this would be triggered by updates that are made to the Company Record.

In Workflow Conditions

And JavaScript is also used to control the triggering of workflow rules.

JavaScript in this example has been used to control when this workflow rule should be available to a user.

In the Component Manager

Another area where JavaScript is used is within the Component Manager

This is relevant to Administrators and Implementation consultants because components are how we can deliver customizations created in one system into another system.

The image above shows the JavaScript that would be generated if I wanted to create a component that would transfer the changes I made in my system into another one.

In the Advanced Email Manager

And JavaScript is used in the Advanced Email Manager.

There are a whole set of articles and videos that cover the Advanced Email Manager

But the rule templates that process inbound emails are all expressed in JavaScript so as you see below we do need to be able use JavaScript.

In other places

Outside of screens, we can add Tab or Button Group actions that call JavaScript – there is a technique called a pseudo URL which allows us to call functions as a button or tab is clicked – I have discussed this in other articles.

And of course ASP pages for application extensions and self-service both use JavaScript. But it is not the only language that we use when working with Sage CRM.

You can use any language that we want to to work with both the SOAP and RESTful web services. That language only needs to be able to create a web request. And so you may prefer to write in PHP or Java.

The .NET API which allows extensions to be created to the main Sage CRM interface can use any .NET capable language, however, we only provide examples in C# within the documentation and training materials.

All the ideas I have discussed in this article have been developed in the other articles within the community. In the next article, I really need to really start looking at the language to allow us to understand the Syntax and available objects.