DocumentService
DocumentService class
Provides static methods with which to convert and merge documents using Apex. This method can be used to convert and merge supported file types to a single PDF, or merge Microsoft Office documents of the same type together. Optionally, you can store the resulting document(s) as Content or Attachment files related to the specified parent record.
Tip: Samples available on GitHub. For more information, see DocumentService samples.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
global class DocumentService
The DocumentService class exposes the following members:
Constructors
Member name | Description |
---|---|
DocumentService class | Creates an instance of the DocumentService class. |
Methods
Member name | Description |
---|---|
DocumentService.ConvertAndMerge method | Initiates the conversion and merging process for the specified list of document, to create a combined document with the specified output file name attached to the specified parent record. |
DocumentService.GetConvertAndMergeRedirect method | Initiates the conversion and merging process for the specified list of documents, to create a combined document with the specified output file name attached to the specified parent record, and optionally returns a PageReference. |
Properties
Member name | Description |
---|---|
DocumentService.usePreview property | Gets or sets whether to run the DocumentService within the preview environment. |
DocumentService constructor
Creates an instance of the DocumentService constructor class.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
DocumentService()
DocumentService properties
The DocumentService class exposes the following members.
Properties
Member name | Description |
---|---|
DocumentService.usePreview property | Gets or sets whether to run the DocumentService within the preview environment. |
DocumentService.usePreview property
Gets or sets whether to run the DocumentService within the preview environment.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
static Boolean usePreview
Property Value
Type: Boolean
true to run the DocumentService within the preview environment; otherwise, false to run the DocumentService within the live environment.
Remarks
If the DocGen Package preview environment is available, either for all organizations or the current organization, set this property to true to execute the static methods included with the DocumentService class within the DocGen Package preview environment. If the DocGen Package preview environment is not available, or if this property is set to false, the static methods included with the DocumentService class run within the DocGen Package live environment.
For more information about the DocGen Package preview environment, see Next release testing.
DocumentService methods
The DocumentService class exposes the following members:
Methods
Member name | Description |
---|---|
DocumentService.ConvertAndMerge method | Initiates the conversion and merging process for the specified list of documents, to create a combined document with the specified output file name attached to the specified parent record. |
DocumentService.GetConvertAndMergeRedirect method | Initiates the conversion and merging process for the specified list of documents, to create a combined document with the specified output file name attached to the specified parent record, and optionally returns a PageReference. |
DocumentService.ConvertAndMerge method
Initiates the conversion and merging process for the specified list of documents, to create a combined document with the specified output file name attached to the specified parent record.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Overload List
Name | Description |
---|---|
DocumentService.ConvertAndMerge(List<Id>, Id, String, Map<String, String>) method | Initiates the conversion and merging process for the specified list of documents, to create a combined document with the specified output file name attached to the specified parent record. |
DocumentService.ConvertAndMerge(List<Id>, Id, String, Map<String, String>, Map<String, String>) method | Initiates the conversion and merging process for the specified list of documents to create a combined document with the specified output file name attached to the specified parent record, and optionally assigns values to specified fields on the created Content or Attachment record(s). |
Initiates the conversion and merging process for the specified list of documents to create combined output files with the specified output file name attached to the specified parent record.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
static String ConvertAndMerge(List<Id> docIds, Id parentId, String outputFilename, Map<String, String> params);
Parameters
docIds
Type: List<Id>
The list of Attachment, Document, ContentDocument, and ContentVersion IDs for documents to be either converted and merged into output files, or converted and merged into a ContentDocument, with an associated ContentVersion, and stored in a specified workspace.
parentId
Type: Id
The ID of the record to which the output files and, optionally, task are attached.
outputFilename
Type: String
The file name of the output files created by the process.
params
Type: Map<String, String>
Additional parameters and values to be used by the process. For more information about additional parameters and values, see Additional parameters and values.
Return value
Type: String
If the trackActivity parameter is set to true in params, the task ID; otherwise, null.
Remarks
This method initiates a process that converts and merges the documents specified in docIds into an attachment, attached to the record specified in parentId, with the file name specified in outputFileName. The process can perform additional actions, such as invoking a callback function after completion of the process, depending on the additional parameters and values specified in params.
Additional parameters and values
The params parameter contains any additional parameters and values to be used by the process. In addition to the set of reserved additional parameters and values, you can also include any arbitrary additional parameters and values in params. All included additional parameters and values are returned in the callback method specified in the apexCallback additional parameter, so you can use the params parameter to provide additional information to the callback method.
The following table describes the additional reserved parameters and values that can be specified in params.
Parameter name | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
workspaceId |
Optional. The ContentWorkspace ID of the library in which to create a corresponding ContentDocument or ContentVersion record for the output file. The process creates one of the following objects, depending on the values specified for this attribute and the contentId attribute:
|
|||||||||||||||
contentId |
Optional. The ContentDocument ID of the document for which to create a corresponding ContentVersion record for the output file. The process creates one of the following objects, depending on the values specified for the workspaceId attribute and this attribute. For more information, see the description for the workspaceId attribute. |
|||||||||||||||
deleteOrig |
Optional. Indicates whether the files specified in docIds should be deleted after the process is successfully completed. If set to true, the original files are deleted; otherwise, the original files are retained. If a value is not specified, the original files are retained. |
|||||||||||||||
mergeType |
Optional. Specifies the type of output file created by the process. This parameter accepts one of the following values:
If a value is not specified, a Portable Document Format (.pdf) file is created. |
|||||||||||||||
trackActivity |
Optional. Indicates whether to create a task to track the status and completion of the process. If set to true, a task is created for the record specified in parentId; otherwise, a task is not created. If a value is not specified, a task is not created. |
|||||||||||||||
outputName | Optional. The name of the output file created by the process. If a value is not specified, the name of the output file is set to "Merged Files". | |||||||||||||||
apexCallback |
Optional. The callback method to be invoked after the completion of the process. The callback method must be specified as a fully-qualified Apex class and method name (for example, ClassName.MethodName) that refers to a static method accessible by the process. The signature of the static method must accept a single string parameter, which contains a JSON-serialized Apex class that provides information about the process. The JSON-serialized Apex class contains the following members:
If a value is not specified, the process does not invoke a callback method after completion. |
Handling callbacks
If the apexCallback parameter is specified in params and the value of the parameter is set to the fully-qualified name of a static method in an Apex class, the process invokes the method after the completion of the conversion and merging process as a callback method, providing information about the process as a string value that represents a JSON-serialized Apex class. The following Apex sample illustrates a minimal callback function, in which the string is deserialized into a private Apex class for later use.
webservice static void myCallback(string responseData)
{
// Deserialize the response data as an
// ConvertAndMergeResponseData instance.
ConvertAndMergeResponseData responseDataObj =
(ConvertAndMergeResponseData)JSON.deserialize(
responseData,
ConvertAndMergeResponseData.class);
}
class ConvertAndMergeResponseData
{
// The Salesforce ID of the Attachment / ContentVersion created as a result of the process
public Id recordId;
// A value, either "success" or "error", indicating the status of the request
public string status;
// Information about an error that occurred as part of the process. Null if status is not "error"
public Error error;
// The version of the package installed
public string requestVersion;
// The original parameters passed to the process
public Map<string, string> requestParameters;
}
class Error
{
// A UUID used to identify the error
public string referenceId;
// A description of the error
public string message;
}
Initiates the conversion and merging process for the specified list of documents, to create a combined document with the specified output file name attached to the specified parent record, optionally replacing specified field tags with corresponding values.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
static String ConvertAndMerge(List<Id> docIds, Id parentId, String outputFilename, Map<String, String> params, Map<String, String> fields)
Parameters
docIds
Type: List<Id>
The list of Document, ContentDocument, and ContentVersion IDs for documents to be converted and merged into an attachment.
parentId
Type: Id
The ID of the record to which the attachment and, optionally, task are attached.
outputFilename
Type: String
The file name of the document created by the process.
params
Type: Map<String, String>
Additional parameters and values to be used by the process. For more information about additional parameters and values, see Remarks.
fields
Type: Map<String, String>
Key-value pairs used to assign values to fields on the generated Attachment or ContentVersion record(s). For example, to populate the MyCustomField__c field on a created Attachment or ContentVersion record with the value, “My Custom Value”, ensure that your Map<string, string> fields parameter has a key with the name, “MyCustomField__c” with a corresponding value of “My Custom Value”.
Return value
Type: String
If the trackActivity parameter is set to true in params, the task ID; otherwise, null.
Remarks
This method initiates a process that converts and merges the documents specified in docIds into an attachment, attached to the record specified in parentId, with the file name specified in outputFileName. The process can perform additional actions, such as invoking a callback function after completion of the process, depending on the attributes and values specified in params. Optionally, if key-value pairs are specified in the fields, those fields will be populated on any generated Attachment or ContentVersion record(s).”
Additional parameters and values
The params parameter contains any additional parameters and values to be used by the process. In addition to the set of reserved additional parameters and values, you can also include any arbitrary additional parameters and values in params. All included additional parameters and values are returned in the callback method specified in the apexCallback additional parameter, so you can use the params parameter to provide additional information to the callback method.
The following table describes the attributes and values that can be specified in params.
Parameter name | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
workspaceId |
Optional. The ContentWorkspace ID of the library in which to create a corresponding ContentDocument or ContentVersion record for the output file. The process creates one of the following objects, depending on the values specified for this attribute and the contentId attribute:
|
||||||||||
contentId |
Optional. The ContentDocument ID of the document for which to create a corresponding ContentVersion record for the output file. The process creates one of the following objects, depending on the values specified for the workspaceId attribute and this attribute. For more information, see the description for the workspaceId attribute. |
||||||||||
deleteOrig |
Optional. Indicates whether the files specified in docIds should be deleted after the process is successfully completed. If set to true, the original files are deleted; otherwise, the original files are retained. If a value is not specified, the original files are retained. |
||||||||||
mergeType |
Optional. Specifies the type of output file created by the process. This parameter accepts one of the following values:
If a value is not specified, a Portable Document Format (.pdf) file is created. |
||||||||||
trackActivity |
Optional. Indicates whether to create a task to track the status and completion of the process. If set to true, a task is created for the record specified in parentId; otherwise, a task is not created. If a value is not specified, a task is not created. |
||||||||||
outputName | Optional. The name of the output file created by the process. If a value is not specified, the name of the output file is set to "Merged Files". | ||||||||||
apexCallback |
Optional. The callback method to be invoked after the completion of the process. The callback method must be specified as a fully-qualified Apex class and method name (for example, ClassName.MethodName) that refers to a static method accessible by the process. The signature of the static method must accept a single string parameter, which contains a JSON-serialized Apex class that provides information about the process. The JSON-serialized Apex class contains the following members:
If a value is not specified, the process does not invoke a callback method after completion. |
Handling callbacks
If the apexCallback attribute is specified in params and the value of the attribute is set to the fully-qualified name of a static method in an Apex class, the process invokes the method after the completion of the conversion and merging process as a callback method, providing information about the process as a string value that represents a JSON-serialized Apex class. The following Apex sample illustrates a minimal callback function, in which the string is deserialized into a private Apex class for later use.
webservice static void myCallback(string responseData)
{
// Deserialize the response data as an
// ConvertAndMergeResponseData instance.
ConvertAndMergeResponseData responseDataObj =
(ConvertAndMergeResponseData)JSON.deserialize(
responseData,
ConvertAndMergeResponseData.class);
}
class ConvertAndMergeResponseData
{
// The Salesforce ID of the Attachment / ContentVersion created as a result of the process
public Id recordId;
// A value, either "success" or "error", indicating the status of the request
public string status;
// Information about an error that occurred as part of the process. Null if status is not "error"
public Error error;
// The version of the package installed
public string requestVersion;
// The original parameters passed to the process
public Map<string, string> requestParameters;
}
class Error
{
// A UUID used to identify the error
public string referenceId;
// A description of the error
public string message;
}
DocumentService.GetApexData method
Note: This API supports the product infrastructure and is not intended to be used directly from your code.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
webService static String GetApexData(String className, String requestInfo)
Parameters
className
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
requestInfo
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
Return value
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
Initiates the conversion and merging process for the specified list of documents, to create a document with the specified output file name attached to the specified parent record, and optionally returns a PageReference.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
static System.PageReference GetConvertAndMergeRedirect(List<Id> docIds, Id parentId, String outputFilename, Map<String, String> params)
Parameters
docIds
Type: List<Id>
The list of Document, ContentDocument, and ContentVersion IDs for documents to be converted and merged into an attachment.
parentId
Type: Id
The ID of the record to which the attachment and, optionally, task are attached.
outputFilename
Type: String
The file name of the document created by the process.
params
Type: Map<String, String>
Additional parameters and values to be used by the process. For more information about additional parameters and values, see DocumentService
Return value
Type: PageReference
If the trackActivity parameter is set to true in params, a reference to the page for the task; otherwise, null.
This method initiates a process that converts and merges the documents specified in docIds into an attachment, attached to the record specified in parentId, with the file name specified in outputFileName. The process can perform additional actions, such as invoking a callback function after completion of the process, depending on the attributes and values specified in params.
If the process creates a task to track the process, by setting the trackActivity attribute to true in params, this method returns a PageReference object that redirects the user to the detail page for the newly created task.
Additional parameters and values
The params parameter contains any additional parameters and values to be used by the process. In addition to the set of reserved additional parameters and values, you can also include any arbitrary additional parameters and values in params. All included additional parameters and values are returned in the callback method specified in the apexCallback additional parameter, so you can use the params parameter to provide additional information to the callback method.
The following table describes the attributes and values that can be specified in params.
Parameter name | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
workspaceId |
Optional. The ContentWorkspace ID of the library in which to create a corresponding ContentDocument or ContentVersion record for the output file. The process creates one of the following objects, depending on the values specified for this attribute and the contentId attribute:
|
||||||||||
contentId |
Optional. The ContentDocument ID of the document for which to create a corresponding ContentVersion record for the output file. The process creates one of the following objects, depending on the values specified for the workspaceId attribute and this attribute. For more information, see the description for the workspaceId attribute. |
||||||||||
deleteOrig |
Optional. Indicates whether the files specified in docIds should be deleted after the process is successfully completed. If set to true, the original files are deleted; otherwise, the original files are retained. If a value is not specified, the original files are retained. |
||||||||||
mergeType |
Optional. Specifies the type of output file created by the process. This parameter accepts one of the following values:
If a value is not specified, a Portable Document Format (.pdf) file is created. |
||||||||||
trackActivity |
Optional. Indicates whether to create a task to track the status and completion of the process. If set to true, a task is created for the record specified in parentId; otherwise, a task is not created. If a value is not specified, a task is not created. |
||||||||||
outputName | Optional. The name of the output file created by the process. If a value is not specified, the name of the output file is set to "Merged Files". | ||||||||||
apexCallback |
Optional. The callback method to be invoked after the completion of the process. The callback method must be specified as a fully-qualified Apex class and method name (for example, ClassName.MethodName) that refers to a static method accessible by the process. The signature of the static method must accept a single string parameter, which contains a JSON-serialized Apex class that provides information about the process. The JSON-serialized Apex class contains the following members:
If a value is not specified, the process does not invoke a callback method after completion. |
Handling callbacks
If the apexCallback attribute is specified in params and the value of the attribute is set to the fully-qualified name of a static method in an Apex class, the process invokes the method after the completion of the conversion and merging process as a callback method, providing information about the process as a string value that represents a JSON-serialized Apex class. The following Apex sample illustrates a minimal callback function, in which the string is deserialized into a private Apex class for later use.
webservice static void myCallback(string responseData)
{
// Deserialize the response data as an
// ConvertAndMergeResponseData instance.
ConvertAndMergeResponseData responseDataObj =
(ConvertAndMergeResponseData)JSON.deserialize(
responseData,
ConvertAndMergeResponseData.class);
}
class ConvertAndMergeResponseData
{
// The Salesforce ID of the Attachment / ContentVersion created as a result of the process
public Id recordId;
// A value, either "success" or "error", indicating the status of the request
public string status;
// Information about an error that occurred as part of the process. Null if status is not "error"
public Error error;
// The version of the package installed
public string requestVersion;
// The original parameters passed to the process
public Map<string, string> requestParameters;
}
class Error
{
// A UUID used to identify the error
public string referenceId;
// A description of the error
public string message;
}
DocumentService.GetEmailTemplateInfo method
Note: This API supports the product infrastructure and is not intended to be used directly from your code.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
webService static String GetEmailTemplateInfo(String emailTemplateIdsAsString)
Parameters
emailTemplateIdsAsString
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
Return value
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
DocumentService.GetSoqlFieldInfo method
Note: This API supports the product infrastructure and is not intended to be used directly from your code.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
webService static String GetSoqlFieldInfo(String ddpId)
Parameters
ddpId
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
Return value
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
DocumentService.GetTrustedDomains method
Note: This API supports the product infrastructure and is not intended to be used directly from your code.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
webService static String GetTrustedDomains()
Return value
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
DocumentService.InitializeOrg method
Note: This API supports the product infrastructure and is not intended to be used directly from your code.
Namespace: LOOP
Package: Nintex DocGen for Salesforce
Syntax
webService static String InitializeOrg(String key)
Parameters
key
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.
Return Value
Type: String
This API supports the product infrastructure and is not intended to be used directly from your code.