Static Resources

They are external scripts capable of doing some action and can be included in client scripts.

Static resources could be third-party libraries or plug-ins that you want to use in your client script. Client script in Zoho CRM allows you to upload these external resources and reference them in your script.

Uploading a Static Resource

  1. Go to Setup > Developer Hub > Client Script. Click the Static Resources tab next to the Client Script tab.

  1. Click New Resource button.
  2. In the Create New Resource pop-up, enter the Name and Description of the resource.
  3. Click Choose File and select the resource (JS file) you want to use in your script.
  4. Click Save.The resource gets uploaded to a static server.

Adding Static Resource to Client Script

  1. Click Static Resources icon in the right pane of the script editor, below the information icon. Click the Add button next to the name of the static resource that you want to add.
  2. The static resource gets added. Here is how the screen looks after the static resource gets added.
  3. At any instant if you want to remove a static resource, click the Remove button that appears when you hover the cursor near the Added button.​

Using the Static Resource in Client Script

You can now invoke a function defined in that static resource and make use of it from a script. Below is the sample script using static resource.

Sample Script


//Get the field value that has to be validated
var ssn = ZDK.Page.getField("SSN");

/*Check if the value is a valid SSN using function in js file.*/
if(is_socialSecurity_Number(ssn)) 
{
//If it is a valid SSN, display confirmation box that "The lead details are  validated". 
ZDK.Client.showConfirmation('The lead details are  validated');
} 
else 
{
//If it is not a valid SSN, display error message that " The lead values are not validated".    
ZDK.Client.showMessage('The lead details are not validated', { type: 'error' });
}

The Javascript file ssnCheck.js is the static resource uploaded, added and used in the Client Script.

Sample Static Resource File - ssnCheck.js



function is_socialSecurity_Number(str)
{
 regexp = /^(?!000|666)[0-8][0-9]{2}-(?!00)[0-9]{2}-(?!0000)[0-9]{4}$/;
  
        if(regexp.test(str))
          {
            return true;
          }
        else
          {
            return false;
          }

}

Note: 

  • The client script feature is available in Enterprise and Ultimate editions of Zoho CRM.
  • The size of each file must not exceed 5 MB.
  • You can upload only JS files and up to 200 files.
  • Ensure that your code is error-free code and upload minified files to reduce network latency.
  • You can import a maximum of five resources per page and all these resources are available to all the scripts on the page.
  • document and window references will not be available during the client script execution. Hence, refrain from adding DOM or window-dependent libraries.