In case you want to remove any form-fields from the generated PDF to download or mail out the PDF. That is possible by setting the “Flatten Type” through APEX.
Flatten Types:
- NONE: Do not remove anything keep as is (this is the same as not setting the Flatten Type)
- REMOVE_CONFIG_ONLY: Remove the configuration JSON file from attachment but do not remove the form fields
- FULL_FLATTEN: Remove the configuration JSON file from attachment and remove the form fields
Create your own class as below or install the unmanaged package by adding this URL to your SFDC domain: /packaging/installPackage.apexp?p0=04t3X000003So7k
Add the following BEFORE Actionable:
global class DO_NOT_DEPLOY_FlattenPdf implements cadmus_core.AbstractBeforeActionable { global void execute(cadmus_core__Actionable__c actionable, Id docConfig, Id objectId, Map<String, Object> inputMap, cadmus_core.ConvertController.ConvertDataModel cdm) {Â Â cadmus_core.MetadataWrapper.flattenTypeStatic = cadmus_core.MetadataWrapper.FLATTEN_TYPE.FULL_FLATTEN;} } |
Following TEST class can be used:
@IsTest public class DO_NOT_DEPLOY_FlattenPdfTest {@IsTest static void testExecute() { // Create test data cadmus_core__Actionable__c actionable = new cadmus_core__Actionable__c(); insert actionable;Id docConfig = ‘005000000000000001’; // Example Id, ensure this is valid in your context Id objectId = ‘005000000000000002’; // Example Id, ensure this is valid in your context Map<String, Object> inputMap = new Map<String, Object>();cadmus_core.ConvertController.ConvertDataModel cdm = new cadmus_core.ConvertController.ConvertDataModel();// Set the initial value of the static variable cadmus_core.MetadataWrapper.flattenTypeStatic = null;// Instantiate the class DO_NOT_DEPLOY_FlattenPdf flattenPdf = new DO_NOT_DEPLOY_FlattenPdf();// Call the execute method flattenPdf.execute(actionable, docConfig, objectId, inputMap, cdm);// Verify that the static variable was set correctly System.assertEquals(cadmus_core.MetadataWrapper.FLATTEN_TYPE.FULL_FLATTEN, cadmus_core.MetadataWrapper.flattenTypeStatic); } } |