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

Running Custom Background Tasks with Vtiger Server Jobs

This article gives you an overview of the Server jobs in Vtiger CRM to run custom background tasks.
A
Abdul Sameer
19 Apr, 2024 - Updated 13 days 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 specific data based on a particular 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 the warehouse system weekly.
  • Importing daily leads from the website to CRM.
  • Generating periodic reports 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.
The job will start running in the background as per the configured frequency.

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

 

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 have an 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.