createRequestItem
This method is used to create an item for a DocuFetch request.
Returns: Created DocuFetchRequestItemInfo
.
cg.DocuFetchRequestItemInfo createRequestItem (Id parentRequestId, cg.DocuFetchRequestInfo requestInfo)
// Create Single Request Item
Id sampleRequestId = 'a1bXXXXXXXXXXXXXXX'; // e.g. DocuFetch request ID
cg.DocuFetchRequestItemInfo newUploadItem = new cg.DocuFetchRequestItemInfo();
newUploadItem.name = 'Upload Item'; // mandatory
newUploadItem.itemType = 'New Upload'; // mandatory
newUploadItem.itemTypeOptions = 'pdf,jpg,png'; // mandatory
newUploadItem.type = 'item';
String parentFolderId = 'a1bXXXXXXXXXXXXXXX';
String parentFolderName = 'Folder 1';
String folderInfo = '{"id": "' + parentFolderId + '", "name":"' + parentFolderName + '"}';
newUploadItem.details = new Map<String, Object>{
'uploadType' => 'initialUpload',
'minFilesUpload' => 1,
'maxFilesUpload' => '5',
'uploadInstructions' => 'Please upload the required documents.',
'parentFolderId' => folderInfo
};
newUploadItem = cg.DocuFetchTools.createRequestItem(sampleRequestId, newUploadItem);
Boolean isSuccess = newUploadItem.result;
if(isSuccess){
System.debug('Created request item: ' + newUploadItem);
}
else{
String message = newUploadItem.message;
System.debug('Create request item fails: ' + message);
}
// If an item with integration service: Review Document
String serviceType = 'Review Document'; // e.g. Review Document, Complete Form or Complete E-Signature
String objectName = 'Account'; // e.g. Account, Case, etc.
List<Map<String, Object>> reviewDocumentTemplateList = cg.DocuFetchTools.getIntegrationServiceTemplates(serviceType, objectName);
Map<String, Object> reviewDocumentTemplate = reviewDocumentTemplateList.get(0); // or get any template from the list
cg.DocuFetchRequestItemInfo reviewDocument = new cg.DocuFetchRequestItemInfo();
reviewDocument.name = 'Review Document Item';
reviewDocument.itemType = 'Review Document';
reviewDocument.itemTypeOptions = JSON.serialize(reviewDocumentTemplate);
reviewDocument.type = 'item';
reviewDocument.details = new Map<String, Object>{
'uploadInstructions' => 'Please review and submit document.'
};
reviewDocument = cg.DocuFetchTools.createRequestItem(sampleRequestId, reviewDocument);
if(reviewDocument.result){
System.debug('Created request item: ' + reviewDocument);
}
else {
System.debug('Create request item fails: ' + reviewDocument.message);
}