LeadSquared Developer Centre

ON THIS PAGE

Batch Jobs


Batch Jobs allow developers to create and execute long-running tasks within LeadSquared, to address custom requirements. They are used to process high volumes of data in a controlled manner without impacting your database or API limits.

Let’s say you want to transfer leads every night from one account to another, or send SMS reminders to thousands of users to check-in/check-out. Using Batch Jobs, you can write some code in Python and then configure the inbuilt scheduler to invoke your code at defined intervals (or on ad hoc basis using API).

You can use Batch Jobs for data export and import, bulk updates, bulk task creation, bulk activity posts, custom report generation, and other data processing needs.

 

What are Batch Jobs?

Batch Jobs are scheduled background programs that run at defined intervals, without any user intervention. They have the following features –

  • Can run from mins to even 24 hrs.
  • Inbuilt scheduler that allows execution at any predefined time on a daily, weekly or monthly basis.
  • Ability to call any third-party API or service.
  • Can connect to the customer’s DB and customer’s ETL DB, retrieve and process data to produce meaningful output.
  • Write any custom code without restriction of pre-allotted APIs or Libraries.
  • Execution environment is independent of the existing LeadSquared App, and highly scalable.

 

When Should I Create a Batch Job?

Whenever you have a lot of records to process, creating a Batch Job (with your own execution logic) is your best solution. Here are some example use cases –

  • Clone/transfer new leads every night from one account to another.
  • Send SMS reminders to all mobile users to check-in or check-out.
  • Read a CSV from a customer’s location and insert/update leads in account.
  • Daily attendance report.
  • Perform incentive ETL jobs; weekly or monthly reports.
  • Advance search on leads and push them to third-party campaigns.
  • Collective reports from more than one Leadsquared account.
  • Generate daily invoices(PDFs) for the day’s sales orders.

 

Plans

The default plan is available with the following limits. Contact us at support@leadsquared.com for more details.

Feature  Description Default Plan
Maximum Batch Jobs The count of the maximum Batch Jobs that can be created in the account. 5 per account
Maximum Executions Per Day The maximum number of times Batch Jobs can be invoked in a day, across the account. If this limit is exceeded, the remaining batch jobs for the day won’t get executed. 24 per account
Maximum Timeout Maximum duration available in the account to execute all Batch Jobs in a day.*

Note: Time elapsed per execution of Batch Job is recorded after completion of execution.
If a job runs more than the maximum timeout value (or left duration for the day), the job terminates abruptly.

240 minutes
Allowed Invocation The maximum number of times one job can be invoked, from scheduler and API, combined. 10 per job
Maximum Retries on Failure In case of job execution failure, you can retry the execution from the beginning. This setting limits the maximum number of retries that can be set per batch job.

Note: If retries are one or more, the sum of all retried execution is considered against “Maximum Timeout”.

1 per job
Minimum Gap b/w Schedules This is applicable to scheduler configuration per Batch Jobs. This is the gap between two consecutive executions of same Batch Job.

For example, assume the minimum gap is 15 mins. The job is required to be scheduled 1st at 1 AM and then at 1.10 AM. This will not be allowed as the 2nd execution should be on or after 1.15 AM.

60 minutes
Maximum Code File Size This is the max size of the code’s zip file that can be uploaded against a Batch Job. 4 MB
Database Access Batch Job code library allows you to connect to your database or ETL database to perform database operations. Disabled

* Assume that 2 Batch Jobs are set up in an account and the maximum timeout value is 1 hour –

Scenario 1 

  • Both the jobs are configured at execution timeout of 1 hour (and are expected to run say 45 mins).
  • 1st job is invoked at 1 AM. It will succeed. Duration consumed is, say, 40 mins. The duration left for usage is 20 mins.
  • 2nd job is invoked at 2 AM. It will get blocked as the duration left for the day is less than the execution timeout of 2nd job (1 hour).

Scenario 2

  • Both jobs start at 1 AM.
  • In this case, both will be allowed to execute,
  • Both jobs complete in 45 mins each.
  • Total consumed duration becomes 90 mins

 

Prerequisites

  1. Knowledge of Python (supported version – 3.7).
  2. Administrator access to a LeadSquared account.
    • If the super admin feature is enabled on your account, then only the super admin user will have access. Admins trying to access the feature will get the following error – “Access Denied – You do not have sufficient permission to access this page. Please contact your administrator.”

Note: The Batch Jobs feature isn’t available by default. To enable it for your account, contact us at support@leadsquared.com.

 

Next Steps

Learn how to Write Code for Batch Jobs.

On this page

© 2024 by MarketXpander Services Pvt Ltd. All Rights Reserved.