New js Folder in Sage CRM v7.2

By | August 16, 2013

In Sage CRM 7.2, a new folder (js) is added under WWWRoot folder. This folder is used to store all the client side script functions which can be directly accessed in Sage CRM.
Suppose you have ClientFunctions.js (JavaScript file);
Till Sage CRM v7.1:
One have to add the client side code in Custom Content section screen. Below is the code snippet.

<script language=”javascript” src=”../CustomPages/ClientFunctions.js”>
</script>

<script>
if (typeof window.addEventListener != ‘undefined’)
window.addEventListener(“load”, Features, false);
else if (window.attachEvent)
window.attachEvent(“onload”, Features);
</script>

Also Read: Development Tip for Select and Deselect All option in Sage CRM
Here, src parameter denotes source for all client side functions; which can be referred on a screen, where above code is added. Feature function defined in the files can be accessed on any screen directly.

function Features()
{
alert (“Welcome to the world of sage CRM7.2”);
}

But, in Sage CRM v7.2 there is no need to explicitly specify the path of Javascript file at a screen level. Under the installation directory of Sage CRM 7.2, if user expands the WWWRoot >> js folder there is a Custom Folder.
Any JavaScript files that are deployed under custom folder can be accessed in all areas of CRM without providing any reference file path. So, now in Sage CRM v7.2, user have to simply write the below code in the custom content and the linking aspect is handled by CRM itself.
In Sage CRM 7.2 versions:

if (typeof window.addEventListener != ‘undefined’)
window.addEventListener(“load”, Features,false);
else if (window.attachEvent)
window.attachEvent(“onload”, Features);
</script>

Sage CRM 7.2 introduced this new feature which does not require the javascript source file to be added into the custom content. Making life easy for the developers 🙂
Related Posts:

1. Calling External URL from Workflow
2. .Net API Validate method for Screen level validations
3. Changing max allowable length of Text field using Jquery
4. Sort Dropdown list items using jQuery