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
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); } } |