Show:      

ConvertController

Signature
global with sharing class ConvertController

ConvertController Methods

convert(data)

Convenient method that converts a DocConfig and returns the ContentVersionId or AttachmentId
Signature
webService static String convert(ConvertDataModel data)
Parameters
data
Type: ConvertDataModel
ConvertDataModel instance to use
Returns
ContentVersionId or AttachmentId (dependent on Delivery Type on DocConfig)
See
Example
 cadmus_core.ConvertController.convert(data);

convertAura(data)

Signature
@AuraEnabled
global static String convertAura(ConvertDataModel data)

convertStandaloneDocToPDF(fileName, document, pdfAction)

Signature
@AuraEnabled
global static String convertStandaloneDocToPDF(String fileName,Blob document,String pdfAction)

convertStandaloneDocToPDFV2(fileName, document, pdfAction, packId, locale, alternativeName)

Signature
@AuraEnabled
global static String convertStandaloneDocToPDFV2(String fileName,Blob document,String pdfAction,String packId,String locale,String alternativeName)

convertToDocx(docConfigId, objectId)

Signature
webService static String convertToDocx(Id docConfigId, Id objectId)
Deprecated
use cadmus_core.ConvertController.convertWithWrapper(data)

convertToDocxAura(docConfigId, objectId)

Signature
@AuraEnabled
global static String convertToDocxAura(Id docConfigId, Id objectId)

convertToPdf(docConfigId, objectId)

Signature
webService static String convertToPdf(Id docConfigId, Id objectId)
Deprecated
use cadmus_core.ConvertController.convertWithWrapper(data)

convertToPdfAura(docConfigId, objectId)

Signature
@AuraEnabled
global static String convertToPdfAura(Id docConfigId, Id objectId)
Deprecated
use cadmus_core.ConvertController.convertWithWrapper(data)

convertWithWrapper(data)

Convert DocConfig or Pack defined in the ConvertDataModel
Signature
webService static DocGenerationWrapper convertWithWrapper(ConvertDataModel data)
Parameters
data
Type: ConvertDataModel
ConvertDataModel instance to use
Returns
DocGenerationWrapper
See
Example
 cadmus_core.ConvertController.ConvertDataModel cdm = new cadmus_core.ConvertController.ConvertDataModel(); 
 cdm.objectId = YOUR_RECORD_ID; //this must be the Id of the record you want to generate from eg an Opportunity Id 
 cdm.docConfigId = YOUR_DOCCONFIG_ID; //the Id of the DocConfig you want to use in your generation, 
           //you can also choose to fill the cdm.packId parameter. Then then docConfigId is not required 
 cadmus_core.DocGenerationWrapper wrapper = cadmus_core.ConvertController.convertWithWrapper(cdm); 
 //Get the name of the generated file: wrapper.response.metadata.targetName 
 //Get the generated file (Blob): wrapper.response.base64

convertWithWrapperAndInputMap(data, inputMap)

Convert DocConfig or Pack defined in the ConvertDataModel with variables and datasources included via the inputMap
Signature
global static DocGenerationWrapper convertWithWrapperAndInputMap(ConvertDataModel data, Map<String, Object> inputMap)
Parameters
data
Type: ConvertDataModel
ConvertDataModel instance to use
inputMap
Type: Map<String, Object>
Map<String, Object) Map that can include extra key/value datasources, parameters for SOQL DataSources, ...
Returns
DocGenerationWrapper
See
Example
Map<String, Object> inputMap = new Map<String, Object>(); 
 //Add a variable of different types - we will process the type correctly 
 //More input on variables: https://www.pdfbutler.com/academy.html?q=Actionable%20run%20APEX%20Class 
inputMap.put('startDate', Date.today()); 
inputMap.put('stage', 'Closed Won'); 
 
 //More info on KeyValue DataSources: https://www.pdfbutler.com/academy.html?q=KeyValue%20DataSources 
 //Add a SINGLE DataSource - You can select data, for demo purposes, we wil use hardcoded data 
Map<String, Object> singleDS = new Map<String, Object>(); 
singleDS.put('fld1', 'val1'); 
singleDS.put('fld2', 'val2'); 
 //Get DS by unique identifier 
cadmus_core__Data_Source__c ds1 = [SELECT Id FROM cadmus_core__Data_Source__c 
                                   WHERE cadmus_core__CustomerDataSourceId__c = '00D2p000000QL9s_a022p00000VKe2M']; 
inputMap.put(ds1.Id, singleDS); 
 
 //Add a LIST DataSource - You can select data, for demo purposes, we wil use hardcoded data 
 //Every Map can be seen as a record we use 
List<Map<String, Object>> listDS = new List<Map<String, Object>>(); 
Map<String, Object> record1 = new Map<String, Object>(); 
record1.put('fld1', 'val1.1'); 
record1.put('fld2', 'val2.1'); 
listDS.add(record1); 
Map<String, Object> record2 = new Map<String, Object>(); 
record2.put('fld1', 'val1.2'); 
record2.put('fld2', 'val2.2'); 
listDS.add(record2); 
 
 //Get DS by unique identifier 
cadmus_core__Data_Source__c ds2 = [SELECT Id FROM cadmus_core__Data_Source__c 
                                  WHERE cadmus_core__CustomerDataSourceId__c = '00D2p000000QL9s_a022p00000VKe2M']; 
inputMap.put(ds2.Id, listDS); 
 
cadmus_core.ConvertController.ConvertDataModel cdm = new cadmus_core.ConvertController.ConvertDataModel(); 
cdm.objectId = '0032p00002SmbiKAAR'; CHANGE THIS //this must be the Id of the record you want to generate from eg an Opportunity Id 
cdm.docConfigId = 'a042p00000wyXDyAAM'; CHANGE THIS //the Id of the DocConfig you want to use in your generation 
 
cadmus_core.DocGenerationWrapper wrapper = cadmus_core.ConvertController.convertWithWrapperAndInputMap(cdm, inputMap); 
 //Get the name of the generated file: wrapper.response.metadata.targetName 
 //Get the generated file (Blob): wrapper.response.base64

ConvertController.ConvertDataModel

Class to capture all required convert data
Signature
global with sharing class ConvertDataModel
Example
 cadmus_core.ConvertController.ConvertDataModel cdm = new cadmus_core.ConvertController.ConvertDataModel();

ConvertController.ConvertDataModel Properties

Name Signature Description
alternativeName
webService String alternativeName
Which Alternative on your DocConfig to use
country
webService String country
Country, only used for DateTime formatting
deliveryOverwrite
webService String deliveryOverwrite
Use this Delivery instead of the one specified on the DocConfig.
Values: 'BASE64', 'FILES','FILES_OVERWRITE', 'FILES_ADD_VERSION', 'ATTACHMENTS', 'ATTACHMENTS_OVERWRITE'
docConfigId
webService Id docConfigId
SFDC Id of the DocConfig. Required when not specifying 'packId' or 'docConfigIds'
docConfigIds
webService List<Id> docConfigIds
Required! If you want to overwrite the DocConfigs in the Pack. List the DocConfig Ids here. A packId is also required
inputMap
global Map<String, Object> inputMap
pass on variables and DataSources
language
webService String language
Language, used for translation (eg TRANSLATION PICKLIST DataSource). By default, the first part of the locale is used. eg de_DE => de
locale
webService String locale
Which Locale to use. Locale is a combination of language and country. eg en_US, fr_CA, fr_BE, de_DE, de_AT
mergeActions
global PdfActions mergeActions
pass on variables and DataSources
numCurrLocale
webService String numCurrLocale
Which Locale to use for Number and Currency formatting. eg en_US, fr_CA, fr_BE, de_DE, de_AT
objectId
webService Id objectId
Required! Record Id in which the convert process has to work
packId
webService Id packId
Id of the PDF Butler pack. Required when no DocConfigId is given
parameters
webService CadmusParameters parameters
There parameters are extra variables that can be used in the DataSources
pdfActionType
webService String pdfActionType
Merge the PDF's or not. In a pack or with Additional PDF's. Values: 'MERGE' or 'NONE'
targetType
webService String targetType
Export type, only used for DOCX convert. Values: PDF, DOCX
timeZone
webService String timeZone
only used for DateTime formatting