Loading
Salesforce now sends email only from verified domains. Read More
Omnistudio Document Generation
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Metering and Throttling for Document Generation

          Metering and Throttling for Document Generation

          Learn how to optimize the performance of your document generation solution with metering and throttling. Metering measures resource utilization levels and throttling controls resource access and use based on defined rules.

          Metering

          Metering measures the number of server-side documents that you generate hourly and daily. The default hourly and daily limits for processing server-side document generation requests can be found in Document Generation Limitations.

          Throttling

          Throttling maintains consistency and resilience of the server-side document generation service by managing incoming server-side document generation requests from multiple orgs. Throttling can also prevent service degradation caused by high volume of requests at peak hours by blocking requests that exceed the default limits. The request details are saved in the Document Generation Processes entity. You can retrieve the blocked requests and retry the server-side document generation.

          View Document Generation Requests

          You can view the document generation requests and their status from the Document Generation Processes page.

          Use this sample URL to view the Document Generation requests: https://{{baseUrl}}/lightning/o/DocumentGenerationProcess/home. Replace the base url with your org details.

          Here's an example of the Document Generation Processes page. In this example, there are blocked document generation requests because the daily limit has been reached.

          List of Document Generation Requests and its Status

          Retrieve Blocked Server-Side Document Generation Requests Using Apex Class

          Retrieve blocked server-side document generation requests for specific timeframes. Blocked requests are reprocessed via new server-side document generation requests.

          Sample Code to Retrieve Blocked Requests

          Modify the sample code to create an Apex class for retrieving blocked server-side document generation requests.

          The required input parameters for the code include:

          Parameter Description
          startTime Start time of the timeframe to retrieve blocked requests.
          endTime End time of the timeframe to retrieve blocked requests.

          Sample Code

          Global class DocGenRetryBlockedBatch implements Database.Batchable<sObject> {
          	private DateTime startTime;
          	private DateTime endTime;
          	public DocGenRetryBlockedBatch(DateTime startTime, DateTime endTime) {
              	this.startTime = startTime;
           	   this.endTime = endTime;
          	}
             
          	global Database.QueryLocator start(Database.BatchableContext BC) {
              	DateTime dt = System.Now().addHours(-1);
              	String query = 'SELECT Id, Type ,RequestText, TokenDataContentDocumentId , TokenData from DocumentGenerationProcess where Status =\'Blocked\' and LastModifiedDate >=:startTime and LastModifiedDate <=:endTime';
              	return Database.getQueryLocator(query);
          	}
          
          
          	global void execute(Database.BatchableContext BC, List<DocumentGenerationProcess> blockedList) {
              	List<DocumentGenerationProcess> ls = new List<DocumentGenerationProcess>();
              	for(DocumentGenerationProcess blockedObject:blockedList)
              	{
                  	DocumentGenerationProcess myCustomObject = new DocumentGenerationProcess (
                      	Type = blockedObject.Type, Status = 'InProgress',
                      	RequestText= blockedObject.RequestText,
                      	TokenDataContentDocumentId= blockedObject.TokenDataContentDocumentId,
                      	TokenData = blockedObject.TokenData
                  	);
                  	ls.add(myCustomObject);  
              	}
              	insert ls;
          	}
             
          	global void finish(Database.BatchableContext BC) {
              	// execute any post-processing operations
               }
          }
          

          Create DocGenRetryBlockedBatch Apex Class

          After creating the code for retrieving blocked requests, create an Apex class in the Developer Console.

          1. Click the quick access menu Setup gear icon and select Developer Console.
          2. Select File | NewApex Class.
          3. For Name, enter the name as DocGenRetryBlockedBatch, and then click OK.
          4. Enter the code that you created for retrieving blocked requests into the dialog.
            For more information, see Sample Code to Retrieve Blocked Requests.
          5. Save your changes.

          Retrieve and Reprocess Blocked Requests

          After creating an Apex class, run the code for retrieving blocked requests in the Developer Console. Ensure that the start time and end time are defined in the Sample Code to Retrieve Blocked Requests.

          1. Click the quick access menu Setup gear icon and select Developer Console.
          2. From the Debug menu, select Open Execute Anonymous Window.
          3. In the Enter Apex Code dialog, enter this sample statement:
            DocGenRetryBlockedBatch dgrb = new DocGenRetryBlockedBatch(
            DateTime.newInstance(2022,10,17), DateTime.now());
            Database.executeBatch(dgrb);
            
          4. Select the statement you pasted.
          5. Click Execute Highlighted.
          6. Close the Developer Console.
           
          Loading
          Salesforce Help | Article