Below is a list of common errors experienced when attempting to generate documents from Salesforce. Here you can reference frequently encountered errors and the suggested corrective action.
Insufficient Privileges: You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.
Please make sure user profiles have access to all the Formstack Documents objects in this article, particularly the Field Mappings object as it's often left out.
Apex CPU time limit exceeded
Overall, this error is caused by the time it takes to pull in the record information. Try the following things in order to resolve:
1. Use the "(Flat / No Related Fields)" option in your mapping for any child relationships. This will reduce the time it takes to pull the information.
Please note that enabling this setting will then only send over data for the child record and not the parent record, so only use this setting for use cases where you are not requiring data from the parent record for this field. And to choose this, you will choose the option with (flat / no related fields) from the dropdown, as in the screenshot below:
2. In your Mapping settings, you can also try to turn on Batch Mode (click the checkbox).
Attempt to dereference a null object error
- Ensure that all mappings are to objects that exist in your Salesforce org.
- Ensure the user has permission to the object and all fields being mapped to within Salesforce.
Apex heap size too large
This is a Salesforce limit. This error means that you are trying to pull more information that Salesforce can save in memory during processing. These are a couple of Salesforce articles that discuss this and best practices:
Some additional considerations:
- If you check “batch mode” and run asynchronously, this will increase the limit to 12 MB. However, if you do batch mode, you will not be able to use "Immediately download document" and most likely won't be able to use the "save document to files" on the Formstack Mapping and will need to set up a Salesforce delivery on the document/data route. This is because running asynchronously takes it outside of the 2-minute window for the API to return those items.
- A way to optimize this is to use SOQL queries to optimize the data that is being sent to only the necessary data. If you are already using SOQL, look to make your SOQL queries more efficient.