CRM On Demand Technical Tips and Tricks: Javascript API - Storing Code

techtips.jpg

This post is part of a series of technical articles on the Javascript API. In this series, we will cover:

  1. Custom buttons.
  2. Storing your code.
  3. Classes, context, the screen, chaining plus the titlebar.
  4. CRUD. Create, Read, Update and Delete records.

In our first blog article in this series, you learned how to create a custom button with a canonical “hello world” program. In this article, we discuss options for storing your Javascript code.

Two Options for Storing Code

The first option is to store the code as a client side extension in CRM On Demand, as discussed in our first blog article. The main benefit of using client side extensions is that Oracle handles everything about the storage. There is no need to worry about having a separate web server with proper configuration of HTTPS; there are no SSL certificates to purchase and configure. The disadvantage is that any changes you make to your code must be loaded separately into each CRM On Demand system that you have. For Oracle partners with many customers, this can be cumbersome.

Therefore, we suggest a second option for storing code. Provide your own HTTP server and store your code there, and then configure CRM On Demand to pull the code from your server. There are several ways to configure CRM On Demand to pull the code. We recommend the long-standing method of creating and enabling an applet.

1. Applet Creation

  • In CRM On Demand, go to Admin, Application Customization, and Global Web Applets.
  • Select the New button.
  • Give the applet any Name you’d like, i.e. HelloWorld.
  • Location should be set to Action Bar.
  • Type is HTML.
  • Web Applet HTML should be a single line of HTML with a script tag having the URL of your code. For instance, if you have it installed on a local web server it could be something like this:<script type="text/javascript" src="https://localhost/js/helloworld.js"></script>
  • Select the Always Run checkbox.
  • Set the Height to 0 (zero).
  • Select Save.

2. Enabling the Applet.

  • In CRM On Demand, go to My Setup, Personal Layout, Action Bar Layout.
  • Move the HelloWorld applet from the Available Sections to the Displayed Sections.
  • Select Save.

When you store helloworld.js on https://localhost/js/, your content may be blocked by your browser. To get around this browser security mechanism in Firefox, set the security.mixed_content.block_active_content flag in Firefox to false (see Firefox’s help for more information). IE, Chrome, and Safari also allow for non-blocking of mixed content. We’ll leave that as an exercise for you to find out how to enable mixed content on your browser of choice.

Configuring an HTTPS server with valid SSL certificates is beyond the scope of this blog series. The Nginx open source web server has gained immense popularity over the past few years. If you’re interested in learning how to configure Nginx as and HTTPS server, check this out.

Our next blog article will discuss more Javascript API work, including working with classes, context, the screen, chaining plus the titlebar.

Don’t forget to subscribe to our quarterly update and get valuable information on CRM Best Practices, User Adoption, CRM On Demand Tips & Techniques, and our upcoming R26 series.