Loading

DocuSign Envelope Update Job Fails with Too Many SOQL Queries 201

Дата публикации: Oct 15, 2026
Описание

Issue

Your org uses Communications Cloud Contract Lifecycle Management (CLM) with DocuSign eSignature (vlocity_cmt managed package). The scheduled Apex class ContractEnvelopeStatusScheduler polls DocuSign for the status of sent envelopes and updates the related Salesforce records. This job can fail when many envelopes are updated at the same time.

Symptoms

  • The Apex job vlocity_cmt.ContractEnvelopeStatusScheduler.doDocuSignEnvelopeUpdates fails.
  • The job reports this error: vlocity_cmt:Too Many SOQL Queries:201
  • The contract document envelope status stays Sent instead of changing to Completed after the recipient signs, or instead of changing to Voided after the sender revokes the signature.
  • The failure is more likely after many envelopes are sent, or signed, in a short period.

Root Cause

The job hits the Apex governor limit on SOQL queries for each transaction. For asynchronous Apex, such as a scheduled job, the limit is 200 SOQL queries, so the 201st query fails.

The ContractEnvelopeStatusScheduler processes envelopes one at a time. For each envelope, it gets the signed document from DocuSign and then updates several Salesforce records based on the envelope status. Depending on the status, each envelope uses about 3–5 SOQL queries. Because the query count grows with every envelope in the run, a large batch (for example, 300 or more envelopes) goes over the SOQL query limit, and the transaction fails with "Too Many SOQL Queries: 201".

This is a documented limitation: the scheduled job can fail when a large number of envelopes are updated in the same timeframe. The fix is to keep the number of envelopes in each run small.

Решение

Lower the number of envelopes that each scheduler run must process. To confirm the cause first, follow the checks below.

Confirm the cause

  1. From Setup, enter Apex Jobs in the Quick Find box, then select Apex Jobs. Find the failed ContractEnvelopeStatusScheduler run.
  2. Check that the failure message is vlocity_cmt:Too Many SOQL Queries:201. If you see a different error, this article doesn't apply. Look up that error instead.
  3. Review how many contract documents were waiting for a DocuSign status update when the job failed. If a large number of envelopes were sent or signed close together, the root cause above applies.

Fix: Lower the envelope count for each run

  1. Run the job every 15 minutes. With more frequent runs, fewer envelopes build up between runs, so each run uses fewer SOQL queries.
    • If you schedule the class from the Salesforce UI, you can only schedule it every hour. To run it more often, schedule the class from the Developer Console (Execute Anonymous window) as four jobs that run 15 minutes apart. Sample code is in Scheduling a DocuSign Job to Poll for Document Signed Status on Salesforce Help.
    • Don't schedule runs closer than 15 minutes apart. DocuSign allows polling at intervals of 15 minutes or more.
  2. Spread out DocuSign sends. Send documents to DocuSign at different times during the day instead of all at once. This lowers the chance that many signed envelopes come back at the same time.
  3. Wait for the next scheduled run. On the Apex Jobs page, check that the run finishes without the SOQL error.

Workaround: Update a single envelope manually

If an important contract document needs its status now, open the contract document and click the Update Envelope Status action. This gets the latest status of that one envelope from DocuSign without waiting for the scheduled job. The action is available only when the contract status is Awaiting Signature.

If the error persists

  • From Setup, enter Scheduled Jobs in the Quick Find box, then select Scheduled Jobs. Make sure only the intended schedules for ContractEnvelopeStatusScheduler are active.
  • If runs still fail at the 15-minute interval, contact Salesforce Support. Include the failed Apex job details and the approximate number of envelopes waiting at the time of the failure.
Номер статьи базы знаний

004634137

 
Загрузка
Salesforce Help | Article