Let’s Work Together



Java Script and Salesforce Hands in Hands

Salesforce has completely changed the way organizations do business by introducing a highly adaptable, customized and easy–to–use platform for end–to–end implementation service. Developers can quickly create and deploy trusted cloud applications that are compact, secure, and accessible without worrying about provisioning hardware or application stacks. Moreover, this platform provides separate tools for defining the data model, the business logic, and the user interface.

JavaScript has always been available to Salesforce developers, but today, JavaScript frameworks have successfully found their rightful place in the Salesforce development lifecycle with the appearance of Lightning, it is now a first-class language on the platform.

Whether you’re creating a fully reformed UI, integrating data from various sources, or using frameworks such as AngularJS, Ember, React, or Backbone, there’ll be situations where you might need to make heavy use of JavaScript. If you have been following web development over the past few years, you will undoubtedly have noticed the increase in the popularity of JavaScript frameworks when it comes to building web applications.

Using JavaScript in Visualforce Pages

While using JavaScript libraries in your Visualforce pages, you will be allowed to:

  • Deliver great user experiences.
  • Customize the functionality of your Visualforce pages.
  • Pass parameters to the JavaScript, show pop-ups, confirm messages, etc.
  • Display Visualforce page validation messages as pop-ups.
  • Call controller methods from JavaScript.
  • Effectively use remote objects (JS data structures that mirror the SFDC database) and action methods (action functions, action support).
  • Create a more responsive experience that’s ideal for mobile pages or any other page where your use case requires maximum efficiency and performance.
  • Access to a wide range of existing JavaScript functionality, such as JavaScript libraries, and other ways to customize the functionality of your pages.

The best way to include JavaScript in a VF page is by placing the JS in a static resource and then calling it from there. For example,

<apex:includeScript value=”{!$Resource.MyJavascriptFile}”/>

You can then use the functions defined within that JavaScript file using <script> tags.

Using JavaScript in Lightning components

JavaScript is a client-side scripting language that runs in a web browser. It has the behaviour of functional programming language and concepts of object-oriented language.

Java Scripts useful expression to make your component more responsive are:

  • Invoking Actions on Component Initialization.
  • Sharing JavaScript Code in a Component Bundle.
  • Sharing JavaScript Code Across Components.
  • Using External JavaScript Libraries.
  • Dynamically Creating Components.
  • Detecting Data Changes with Change Handlers.
  • Finding Components by ID.
  • Working with events in JavaScript.
  • Modifying the DOM.
  • Dynamically adding event handlers to a component.
  • Dynamically showing or hiding a markup.
  • Adding and removing styles from during runtime.
  • Making API callsfrom component.
  • Manage CSP trusted sites.

Software ate the world… and the cloud is eating software. – Marc Benioff