Articles in this section
Running Custom Background Tasks with Vtiger Server Jobs
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:
- Log in to your CRM account.
- Click the Main Menu.
- Click Platform.
- Select Server Jobs. You will see a list of available server jobs.
- Click the Add Server Job.
- Enter or select information for the following
- Job Name: Enter a name for the job.
- Assigned to: Select a user from the drop-down to assign the job.
- Frequency: Select a frequency from the drop-down and select the desired duration.
- Click Save.
- Type your code in the provided editor.
- Click the Playground tab.
- Click Execute and Verify to validate your code.
- Change the Status to Active to run the job.
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:
|