Home  >   VTAP Platform   >  Running Custom Background Tasks with Vtiger Server Jobs

Running Custom Background Tasks with Vtiger Server Jobs

A
Abdul Sameer
15 Mar, 2024 - Updated 1 month ago
Table of Contents

Introduction

Server Jobs are background jobs which run periodically based on configured frequency (hourly, daily, weekly, etc). This should be used for heavy and periodic operations like fetching data from external services and creating them in CRM, or sending some data based on some logic to external services, etc.

These are run in the background and no CRM operation is blocked. Based on configured frequency, they are picked and sent to service for execution. Service queues them and executes based on its own load. After execution, the service sends the result back to the CRM. No user or record data is passed to the script and it runs on owner user context.

 

Use Cases

  • Update available stocks to warehouse system weekly
  • Importing daily leads from the website to CRM
  • Generating periodic report using CRM data based on custom business logic
 

Creating Server Jobs

You can create server jobs in the Server Jobs module in the CRM. Follow these steps to create a new server job:

  1. Log in to your CRM account.
  2. Click the Main Menu.
  3. Click Platform.
  4. Select Server Jobs. You will see a list of available server jobs.
  5. Click the Add Server Job.
  6. Enter or select information for the following
    1. Job Name: Enter a name for the job.
    2. Assigned to: Select a user from the drop-down to assign the job.
    3. Frequency: Select a frequency from the drop-down and select the desired duration.
  7. Click Save.
  8. Type your code in the provided editor.
  9. Click the Playground tab.
  10. Click Execute and Verify to validate your code.
  11. Change the Status to Active to run the job.
  12. Job will start running in background as per configured frequency.
 

You can view the execution logs of Server Jobs running in background. To view logs, click on Logs button in Server Jobs page. You can click on each log to see it's full detail.

 

Code Format

async function main() {
    //Type your code here

}
 

Kindly refer this document to learn more about how to code, helper methods, etc.

 
Note:
  • Hourly background job should not take more than 90 sec for execution else it will be killed.
  • Other frequency jobs should not take more than 4 minutes for execution else they will be killed.
  • Background jobs cannot consume more than 128 MB of memory else it will be killed.
  • Background jobs has execution limit per day as per your CRM edition. If there are more jobs to run, they will be executed next day
    • Growth Editions - 1 job per day
    • Professional Editions - 3 jobs per day
    • Enterprise Editions - 5 jobs per day
Was this article helpful?
0  out of  0  found this helpful.
Comments 0
Be the first to comment
© Copyright 2023 Vtiger. All rights reserved.