Home  >   VTAP Platform   >  Writing Code for Server Scripts and Jobs

Writing Code for Server Scripts and Jobs

This article gives you a checklist on how to write codes for the Server Scripts and jobs in Vtiger CRM.
Abdul Sameer
19 Apr, 2024 - Updated 3 months ago
Table of Contents

Writing Scripts

  • Scripts & Jobs are written in Javascript (ES5).
  • As of now, other programming languages are not supported.
  • All the code must be within the main() method. Anything outside this method will not execute.
  • The main method is invoked automatically and you do not need to call it.
  • You can utilize basic JavaScript methods like Math functions, JSON, String, etc.
  • You can also use helper methods provided like HTTP request methods, Vtiger’s REST API methods, and log methods for debugging.

Helper Methods

Following are a few helper methods provided which are available by default to make your work easier:

  • Debugging methods: To make coding easier and debug, there is a log() method. Logs added can be viewed while test execution and in script/job logs. You can also use JavaScript's console methods to debug.
  • HTTP request methods: To send HTTP requests to external services, methods are available (vtap.macro.http)
  • Vtiger REST API methods: To make REST API calls to the CRM instance, you can use vtap.macro.ws

To learn more about helper methods and see code in action, refer to the below examples 


  • Code must be within the main() method, anything outside will not be executed.
  • Server script execution has a limit of 15 sec and 32 MB of memory.
  • Hourly server jobs can run for up to 90 sec with 128 MB of memory.
  • Other server jobs can run for up to 4 mins with 128 MB of memory.
  • Scheduled workflows or processes cannot use server scripts.
  • Daily execution limits apply to server scripts and jobs. If exceeded, they run the next day or are skipped.
  • Certain JavaScript methods like setTimeout, setInterval, and eval are restricted due to potential security risks or delays in execution.
  • Importing external modules using require or import is restricted for security reasons.
  • Use await instead of .then() to handle promises from HTTP requests and Vtiger's REST API methods.
  • Use try-catch to handle errors from requests and REST API methods.
  • HTTP requests are only allowed for secure websites (https) with valid SSL certificates.
  • Direct IPs, localhost, and Vtiger domains are not allowed for HTTP requests, except the CRM instance URL where the script is invoked.
Was this article helpful?
0  out of  0  found this helpful.
Comments 0
Be the first to comment
© Copyright 2023 Vtiger. All rights reserved.